Skip to content

Commit

Permalink
Revert "Expose Storage _use_count API in Python (pytorch#139426)"
Browse files Browse the repository at this point in the history
This reverts commit e31136d.

Reverted pytorch#139426 on behalf of https://github.com/huydhn due to Sorry for reverting your change, but it is failing some inductor job in trunk ([comment](pytorch#139426 (comment)))
  • Loading branch information
pytorchmergebot authored and rahulsingh-intel committed Nov 5, 2024
1 parent 42cc947 commit a1bd2bd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
13 changes: 0 additions & 13 deletions test/test_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10057,19 +10057,6 @@ def __del__(self):
self.assertEqual(MyStorage.finalized_count, 1)
self.assertTrue(m[0])

@unittest.skipIf(not torch.cuda.is_available(), "_storage_Use_Count only registered when CUDA is available")
def test_storage__use_count_APIs_align(self):
a = torch.rand(2, 3)
s = a.untyped_storage()
init_use_count = s._use_count()
self.assertEqual(init_use_count, torch._C._storage_Use_Count(s._cdata))
b = a.t()
self.assertEqual(s._use_count(), init_use_count + 1)
self.assertEqual(s._use_count(), torch._C._storage_Use_Count(s._cdata))
del b
self.assertEqual(s._use_count(), init_use_count)
self.assertEqual(s._use_count(), torch._C._storage_Use_Count(s._cdata))

def test_tensor_ressurecting_clear(self):
# Regression test for https://github.com/pytorch/pytorch/issues/136358
# A Tensor with custom __dict__
Expand Down
8 changes: 0 additions & 8 deletions torch/csrc/StorageMethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ static PyObject* THPStorage_nbytes(PyObject* self, PyObject* noargs) {
END_HANDLE_TH_ERRORS
}

static PyObject* THPStorage__useCount(PyObject* self, PyObject* noargs) {
HANDLE_TH_ERRORS
THPStorage_assertNotNull(self);
return py::cast(THPStorage_Unpack(self).use_count()).release().ptr();
END_HANDLE_TH_ERRORS
}

static PyObject* THPStorage_dataPtr(PyObject* self, PyObject* noargs) {
HANDLE_TH_ERRORS
// PyLong_FromVoidPtr should not need to mutate the pointer in order
Expand Down Expand Up @@ -627,7 +620,6 @@ static PyMethodDef THPStorage_methods[] = {
METH_VARARGS | METH_STATIC,
nullptr},
{"_set_from_file", THPStorage_setFromFile, METH_VARARGS, nullptr},
{"_use_count", THPStorage__useCount, METH_NOARGS, nullptr},
{"from_buffer",
castPyCFunctionWithKeywords(THPStorage_fromBuffer),
METH_VARARGS | METH_KEYWORDS | METH_STATIC,
Expand Down

0 comments on commit a1bd2bd

Please sign in to comment.