Rename tensor.is_named to has_named, expose has_named to python.

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

Test Plan:
- [namedtensor ci]

gh-metadata: pytorch pytorch 23315 gh/zou3519/79/head

Imported from OSS

Differential Revision: D16494414

Pulled By: zou3519

fbshipit-source-id: d2d6beb45db9288e5df707b68b6046d783ca9f97
This commit is contained in:
Richard Zou
2019-07-31 07:07:05 -07:00
committed by Facebook Github Bot
parent 725e41e955
commit c5482e33e9
14 changed files with 42 additions and 17 deletions

View File

@ -146,6 +146,16 @@ static PyObject * THPVariable_get_device(PyObject* self_, PyObject* args)
END_HANDLE_TH_ERRORS
}
#ifdef BUILD_NAMEDTENSOR
static PyObject * THPVariable_has_names(PyObject* self_, PyObject* args)
{
HANDLE_TH_ERRORS
auto& self = reinterpret_cast<THPVariable*>(self_)->cdata;
return wrap(self.has_names());
END_HANDLE_TH_ERRORS
}
#endif
static PyObject * THPVariable_data_ptr(PyObject* self_, PyObject* args)
{
HANDLE_TH_ERRORS
@ -763,6 +773,9 @@ PyMethodDef variable_methods[] = {
{"cuda", (PyCFunction)THPVariable_cuda, METH_VARARGS | METH_KEYWORDS, NULL},
{"data_ptr", (PyCFunction)THPVariable_data_ptr, METH_NOARGS, NULL},
{"dim", (PyCFunction)THPVariable_dim, METH_NOARGS, NULL},
#ifdef BUILD_NAMEDTENSOR
{"has_names", (PyCFunction)THPVariable_has_names, METH_NOARGS, NULL},
#endif
{"double", (PyCFunction)THPVariable_double, METH_NOARGS, NULL},
{"element_size", (PyCFunction)THPVariable_element_size, METH_NOARGS, NULL},
{"float", (PyCFunction)THPVariable_float, METH_NOARGS, NULL},