Revert "Make Generator an Opaque Object (#179661)"

This reverts commit 18357d9483.

Reverted https://github.com/pytorch/pytorch/pull/179661 on behalf of https://github.com/yushangdi due to breaks pr_time_benchmarks ([comment](https://github.com/pytorch/pytorch/pull/179661#issuecomment-4285042651))
This commit is contained in:
PyTorch MergeBot
2026-04-21 00:09:01 +00:00
parent b2e1f526d2
commit cb242afe1b
11 changed files with 21 additions and 155 deletions
+3 -3
View File
@@ -241,7 +241,7 @@ static PyObject* THPModule_initExtension(
auto module = THPObjectPtr(PyImport_ImportModule("torch"));
if (!module)
throw python_error(); // @allow-raw-throw
throw python_error();
THPStorage_postInit(module);
THPAutograd_initFunctions();
@@ -473,7 +473,7 @@ static PyObject* THPModule_addDocStr(PyObject* _unused, PyObject* args) {
m->d_getset->name);
}
m->d_getset->doc = doc_str;
} else if (PyType_Check(obj)) {
} else if (Py_TYPE(obj) == &PyType_Type) {
PyTypeObject* t = reinterpret_cast<PyTypeObject*>(obj);
if (t->tp_doc) {
return PyErr_Format(
@@ -682,7 +682,7 @@ static PyObject* THPModule_torchDeviceToDLDevice(
auto tuple = PyTuple_New(2);
if (!tuple) {
throw python_error(); // @allow-raw-throw
throw python_error();
}
PyTuple_SET_ITEM(tuple, 0, THPUtils_packInt64(dl_device.device_type));