Skip to content

Conversation

@gchanan
Copy link
Contributor

@gchanan gchanan commented Aug 13, 2018

No description provided.

@gchanan
Copy link
Contributor Author

gchanan commented Aug 13, 2018

This is a direct rebase/merge of #10421; I have not yet reviewed this code.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Summary: Fix leaking of Storages (not StorageImpls)

Reviewed By: li-roy

Differential Revision: D9349824

fbshipit-source-id: d492d7d62be393cbc5955440278bd605e04767a4
@gchanan
Copy link
Contributor Author

gchanan commented Aug 15, 2018

This should be ready to review.

Some notes:

  1. There are still some member variables that are publicly accessible in TensorImpl; we need to rework TH to remove these.
  2. I removed unsafeGetTH because there are no longer THTensors. There's a little complexity with this because the closest equivalent (unsafeGetTensorImpl) is a bit confusing for Variable::Impls since a Variable::Impl is both "is-a" and "has-a" TensorImpl. The function returns the "is-a", and you have to know what you are doing to extract the data. This seems more-or-less fine, but may confuse external users (hopefully there aren't any). And this shouldn't be a long term problem, because we are planning to get rid of the "has-a" case.
  3. I included a StorageImpl * accessor in TensorImpl because it makes things convenient temporarily. This should be changed to use intrusive_ptr.
  4. Because of Variable::Impl (and sometimes, SparseTensorImpl), a bunch of these functions are virtual when they don't really have to be. This unfortunately makes a bunch of functions in TH virtual as well, but this should only be temporary.
  5. For the familiar reason of Variable::Impl, this doesn't merge the size data member usage in TensorImpl and SparseTensorImpl.

return size_[d];
}
int64_t SparseTensorImpl::stride(int64_t d) const {
AT_ERROR("sparse tensors do not have strides");

This comment was marked as off-topic.

auto type = &globalContext().getType(tensorTypeIdToBackend(type_id), scalar_type);
auto storage = type->storage(true);
storage_ = storage->pImpl();
storage_->retain();

This comment was marked as off-topic.

if (storage_) {
storage_->release();
storage_ = nullptr;
}

This comment was marked as off-topic.

This comment was marked as off-topic.

tensor->release();
tensor = nullptr;
if (storage_) {
storage_->release();

This comment was marked as off-topic.

This comment was marked as off-topic.

#define TH_GENERIC_FILE "generic/THTensor.h"
#else

/* a la lua? dim, storageoffset, ... et les methodes ? */

This comment was marked as off-topic.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Aug 16, 2018
Summary: Pull Request resolved: pytorch/pytorch#10479

Differential Revision: D9315800

Pulled By: gchanan

fbshipit-source-id: b13ef0de3342600b02b54e0700eb02021a9d1a9e
@ezyang ezyang added the merged label Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants