diff --git a/test/test_torch.py b/test/test_torch.py index 03929f1ee7e6d..2b80384100b98 100644 --- a/test/test_torch.py +++ b/test/test_torch.py @@ -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__ diff --git a/torch/csrc/StorageMethods.cpp b/torch/csrc/StorageMethods.cpp index f74dd8348554b..7200688dd475b 100644 --- a/torch/csrc/StorageMethods.cpp +++ b/torch/csrc/StorageMethods.cpp @@ -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 @@ -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,