-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Cache isContiguous and numel #10696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache isContiguous and numel #10696
Conversation
ea4bc82 to
9aa839e
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpuhrsch has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
aten/src/ATen/TensorImpl.h
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/TH/THTensor.cpp
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/TH/THTensor.hpp
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/TH/THTensor.cpp
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/TH/THTensor.hpp
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/TH/THTensor.hpp
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/TH/THTensor.hpp
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/THC/THCTensor.cpp
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
de1c620 to
da5442f
Compare
|
The PR is misnamed, it caches numel too |
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpuhrsch has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
| } | ||
| void SparseTensorImpl::set_storage_offset(int64_t storage_offset) { | ||
| AT_ERROR("sparse tensors does not have set_storage_offset"); | ||
| } |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| protected: | ||
| void refresh_numel() { | ||
| int64_t n = 1; | ||
| for (auto s : sizes()) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/ATen/TensorImpl.cpp
Outdated
| return numel_; | ||
| } | ||
|
|
||
| void TensorImpl::refresh_contiguous() { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/ATen/TensorImpl.cpp
Outdated
| for (auto s : sizes()) { | ||
| n *= s; | ||
| } | ||
| AT_ASSERT(n == numel_); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| virtual int64_t numel() const; | ||
|
|
||
| virtual bool is_contiguous() const { | ||
| return is_contiguous_; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
ezyang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anything blocking, and since this has a codemod please feel free to merge. But plenty of things to clean up in follow up diffs! (Or if you're unlucky enough to need to rebase, try to roll some of the suggested changes into this patch.)
aten/src/ATen/TensorImpl.h
Outdated
| } | ||
|
|
||
| // WARNING: This function does not check if the requested | ||
| // sizes/strides are in bounds for the storage is allocated; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| virtual void resize_dim(int64_t ndim) { | ||
| // NB: This is *truly* a resize; calling code (e.g., squeeze) | ||
| // assumes that old values are preserved | ||
| sizes_.resize(ndim); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/ATen/TensorImpl.cpp
Outdated
| } | ||
|
|
||
| void TensorImpl::refresh_contiguous() { | ||
| is_contiguous_ = true; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
|
||
| ~Impl() override; | ||
|
|
||
| int64_t numel() const override; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpuhrsch has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
Still have to overwrite is_contiguous() in variable::impl |
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpuhrsch has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
aten/src/ATen/TensorImpl.h
Outdated
|
|
||
| // WARNING: This function does not check if the requested | ||
| // sizes/strides are in bounds for the storage is allocated; | ||
| // sizes/strides are in bounds bounds for the storage that is allocated; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| } | ||
|
|
||
| bool Variable::Impl::is_contiguous() const { | ||
| AT_ERROR("variable impl does not have is_contiguous"); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/ATen/SparseTensorImpl.cpp
Outdated
| AT_ERROR("sparse tensors do not have strides"); | ||
| } | ||
| bool SparseTensorImpl::is_contiguous() const { | ||
| AT_ERROR("sparse tensors does not have is_contiguous"); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpuhrsch has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Pull Request resolved: pytorch/pytorch#10696 Differential Revision: D9437963 Pulled By: cpuhrsch fbshipit-source-id: 7217682f5e4b69c73d943411d738e4892bb465f5
Summary: Pull Request resolved: pytorch#10696 Differential Revision: D9437963 Pulled By: cpuhrsch fbshipit-source-id: 7217682f5e4b69c73d943411d738e4892bb465f5
No description provided.