Allocate empty tensor instead of empty_like in binary ops, fix pow#26498
Closed
zou3519 wants to merge 1 commit intogh/zou3519/180/basefrom
Closed
Allocate empty tensor instead of empty_like in binary ops, fix pow#26498zou3519 wants to merge 1 commit intogh/zou3519/180/basefrom
zou3519 wants to merge 1 commit intogh/zou3519/180/basefrom
Conversation
We should allocate an empty tensor as a result tensor when performing binary ops. Currently some ops use `empty_like(self)` as the initial result tensor before passing it into TensorIterator. This is not very efficient because TensorIterator may resize the tensor due to broadcasting, causing more memory allocation. By using an empty tensor as the result tensor, we only need to allocate/resize memory once as opposed to twice. Also fixes #26495. The bug there is that the implementation of `pow` is missing a resize in one case. Test Plan: - new test - run tests
zou3519
added a commit
that referenced
this pull request
Sep 19, 2019
We should allocate an empty tensor as a result tensor when performing binary ops. Currently some ops use `empty_like(self)` as the initial result tensor before passing it into TensorIterator. This is not very efficient because TensorIterator may resize the tensor due to broadcasting, causing more memory allocation. By using an empty tensor as the result tensor, we only need to allocate/resize memory once as opposed to twice. Also fixes #26495. The bug there is that the implementation of `pow` is missing a resize in one case. Test Plan: - new test - run tests ghstack-source-id: 0705c58 Pull Request resolved: #26498
pbelevich
approved these changes
Sep 20, 2019
zdevito
pushed a commit
to zdevito/ATen
that referenced
this pull request
Sep 20, 2019
…26498) Summary: Pull Request resolved: pytorch/pytorch#26498 We should allocate an empty tensor as a result tensor when performing binary ops. Currently some ops use `empty_like(self)` as the initial result tensor before passing it into TensorIterator. This is not very efficient because TensorIterator may resize the tensor due to broadcasting, causing more memory allocation. By using an empty tensor as the result tensor, we only need to allocate/resize memory once as opposed to twice. Also fixes pytorch/pytorch#26495. The bug there is that the implementation of `pow` is missing a resize in one case. Test Plan: - new test - run tests Differential Revision: D17500025 Pulled By: zou3519 fbshipit-source-id: bff4949af5e75541c04669b961bcf2e1ec456faf
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack:
We should allocate an empty tensor as a result tensor when performing
binary ops. Currently some ops use
empty_like(self)as the initialresult tensor before passing it into TensorIterator. This is not very
efficient because TensorIterator may resize the tensor due to
broadcasting, causing more memory allocation. By using an empty tensor
as the result tensor, we only need to allocate/resize memory once as
opposed to twice.
Also fixes #26495. The bug
there is that the implementation of
powis missing a resize in onecase.
Test Plan:
Differential Revision: D17500025