Skip to content

Commit

Permalink
mark Storage functions as const (#12623)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch/pytorch#12623

Mark Storage functions as const so that they they can be exposed outside of TensorImpl when calling storage()

Based on this discussion #27 (comment)

Also potentially useful in the effort to remove ShareExternalPointer

Reviewed By: ezyang

Differential Revision: D10370201

fbshipit-source-id: 43cf3803a4aa7b94fdf0c3a604d7db769ca0bdd5
  • Loading branch information
ajyu authored and facebook-github-bot committed Oct 15, 2018
1 parent 8cf7e6d commit 9eac8a7
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions aten/src/ATen/core/Storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ struct CAFFE2_API Storage {
}

// TODO: remove later
void set_numel(int64_t numel) {
storage_impl_->set_numel(numel);
void set_numel(int64_t numel) const {
storage_impl_.get()->set_numel(numel);
}

bool resizable() const {
Expand All @@ -94,10 +94,6 @@ struct CAFFE2_API Storage {
}
// get() use here is to get const-correctness

void* data() {
return storage_impl_->data();
}

void* data() const {
return storage_impl_.get()->data();
}
Expand All @@ -115,12 +111,12 @@ struct CAFFE2_API Storage {
}

// Returns the previous data_ptr
at::DataPtr set_data_ptr(at::DataPtr&& data_ptr) {
return storage_impl_->set_data_ptr(std::move(data_ptr));
at::DataPtr set_data_ptr(at::DataPtr&& data_ptr) const {
return storage_impl_.get()->set_data_ptr(std::move(data_ptr));
};

void set_dtype(const caffe2::TypeMeta& data_type) {
storage_impl_->set_dtype(data_type);
void set_dtype(const caffe2::TypeMeta& data_type) const {
storage_impl_.get()->set_dtype(data_type);
}

DeviceType device_type() const {
Expand Down

0 comments on commit 9eac8a7

Please sign in to comment.