Remove remaining THC code (#69039)

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/69039

Test Plan: Imported from OSS

Reviewed By: anjali411

Differential Revision: D32872476

Pulled By: ngimel

fbshipit-source-id: 7972aacc24aef9450fb59b707ed6396c501bcb31
This commit is contained in:
Peter Bell
2021-12-08 12:14:23 -08:00
committed by Facebook GitHub Bot
parent 7407e3d6fd
commit e279963eef
35 changed files with 20 additions and 289 deletions

View File

@ -34,7 +34,6 @@
using namespace torch;
THCState *state = nullptr;
static bool in_bad_fork = false; // True for children forked after cuda init
#ifndef WIN32
@ -42,7 +41,6 @@ static bool in_bad_fork = false; // True for children forked after cuda init
static void forked_child() {
in_bad_fork = true;
torch::utils::set_run_yet_variable_to_false();
state = nullptr;
}
#endif
@ -522,7 +520,7 @@ static PyObject * THCPModule_initExtension(PyObject *self, PyObject *noargs)
HANDLE_TH_ERRORS
TORCH_INTERNAL_ASSERT(!in_bad_fork); // Handled at python level
poison_fork();
state = at::globalContext().lazyInitCUDA();
at::globalContext().lazyInitCUDA();
auto m = THPObjectPtr(PyImport_ImportModule("torch.cuda"));
if (!m) throw python_error();
@ -542,10 +540,6 @@ static PyObject * THCPModule_initExtension(PyObject *self, PyObject *noargs)
set_module_attr("has_magma", at::hasMAGMA() ? Py_True : Py_False);
set_module_attr("has_half", has_half ? Py_True : Py_False);
auto _state_cdata = THPObjectPtr(PyLong_FromVoidPtr(state));
if (!_state_cdata) throw python_error();
set_module_attr("_state_cdata", _state_cdata.get());
auto num_gpus = c10::cuda::device_count();
auto default_cuda_generators = PyTuple_New(static_cast<Py_ssize_t>(num_gpus));
for(const auto i : c10::irange(num_gpus)) {