Warn when tracing legacy constructors

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

Differential Revision: D13963581

Pulled By: driazati

fbshipit-source-id: 8f8cdfc455ba65be370fd952fc5e5c233525d002
This commit is contained in:
David Riazati
2019-02-05 18:22:17 -08:00
committed by Facebook Github Bot
parent 7bf7a4162d
commit 18edd3ab08
4 changed files with 18 additions and 0 deletions

View File

@ -480,6 +480,7 @@ static PyObject * THPVariable_new(PyObject* self, PyObject* args, PyObject* kwar
static PyObject * THPVariable_new_empty(PyObject* self, PyObject* args, PyObject* kwargs)
{
HANDLE_TH_ERRORS
jit::tracer::warn("new_empty", jit::tracer::LEGACY_CONSTRUCTOR);
auto& self_ = reinterpret_cast<THPVariable*>(self)->cdata;
OptionalDeviceGuard device_guard(device_of(self_));
return THPVariable_Wrap(torch::utils::new_empty(self_.type(), args, kwargs));
@ -489,6 +490,7 @@ static PyObject * THPVariable_new_empty(PyObject* self, PyObject* args, PyObject
static PyObject * THPVariable_new_full(PyObject* self, PyObject* args, PyObject* kwargs)
{
HANDLE_TH_ERRORS
jit::tracer::warn("new_full", jit::tracer::LEGACY_CONSTRUCTOR);
auto& self_ = reinterpret_cast<THPVariable*>(self)->cdata;
OptionalDeviceGuard device_guard(device_of(self_));
return THPVariable_Wrap(torch::utils::new_full(self_.type(), args, kwargs));
@ -498,6 +500,7 @@ static PyObject * THPVariable_new_full(PyObject* self, PyObject* args, PyObject*
static PyObject * THPVariable_new_ones(PyObject* self, PyObject* args, PyObject* kwargs)
{
HANDLE_TH_ERRORS
jit::tracer::warn("new_ones", jit::tracer::LEGACY_CONSTRUCTOR);
auto& self_ = reinterpret_cast<THPVariable*>(self)->cdata;
OptionalDeviceGuard device_guard(device_of(self_));
return THPVariable_Wrap(torch::utils::new_ones(self_.type(), args, kwargs));
@ -507,6 +510,7 @@ static PyObject * THPVariable_new_ones(PyObject* self, PyObject* args, PyObject*
static PyObject * THPVariable_new_tensor(PyObject* self, PyObject* args, PyObject* kwargs)
{
HANDLE_TH_ERRORS
jit::tracer::warn("new_tensor", jit::tracer::LEGACY_CONSTRUCTOR);
auto& self_ = reinterpret_cast<THPVariable*>(self)->cdata;
OptionalDeviceGuard device_guard(device_of(self_));
return THPVariable_Wrap(torch::utils::new_tensor(self_.type(), args, kwargs));
@ -516,6 +520,7 @@ static PyObject * THPVariable_new_tensor(PyObject* self, PyObject* args, PyObjec
static PyObject * THPVariable_new_zeros(PyObject* self, PyObject* args, PyObject* kwargs)
{
HANDLE_TH_ERRORS
jit::tracer::warn("new_zeros", jit::tracer::LEGACY_CONSTRUCTOR);
auto& self_ = reinterpret_cast<THPVariable*>(self)->cdata;
OptionalDeviceGuard device_guard(device_of(self_));
return THPVariable_Wrap(torch::utils::new_zeros(self_.type(), args, kwargs));