Comment on a set of ops bound at the python layer

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

Test Plan: Imported from OSS

Reviewed By: suo

Differential Revision: D18713999

Pulled By: eellison

fbshipit-source-id: 3a8d6e4431cbfe6a78ca047217c1c53c47403841
This commit is contained in:
Elias Ellison
2019-11-26 13:44:24 -08:00
committed by Facebook Github Bot
parent 634f370c63
commit 976d91d30a
2 changed files with 24 additions and 0 deletions

View File

@ -59,6 +59,8 @@ static PyObject * THPVariable__is_view(PyObject *self, PyObject* args)
END_HANDLE_TH_ERRORS
}
// implemented on the python object bc no support for first-class functions in native_functions.yaml
// See: ATen/native/README.md for more context
static PyObject * THPVariable_apply_(PyObject* self, PyObject* arg)
{
HANDLE_TH_ERRORS
@ -139,6 +141,7 @@ static PyObject * THPVariable_stride(PyObject* self, PyObject* args, PyObject* k
END_HANDLE_TH_ERRORS
}
// implemented on the python object to avoid dispatch overhead
static PyObject * THPVariable_get_device(PyObject* self_, PyObject* args)
{
HANDLE_TH_ERRORS
@ -157,6 +160,7 @@ static PyObject * THPVariable_has_names(PyObject* self_, PyObject* args)
}
#endif
// implemented on the python object to avoid dispatch overhead
static PyObject * THPVariable_data_ptr(PyObject* self_, PyObject* args)
{
HANDLE_TH_ERRORS
@ -165,6 +169,7 @@ static PyObject * THPVariable_data_ptr(PyObject* self_, PyObject* args)
END_HANDLE_TH_ERRORS
}
// implemented on the python object to avoid dispatch overhead
static PyObject * THPVariable_storage_offset(PyObject* self_, PyObject* args)
{
HANDLE_TH_ERRORS
@ -173,6 +178,7 @@ static PyObject * THPVariable_storage_offset(PyObject* self_, PyObject* args)
END_HANDLE_TH_ERRORS
}
// implemented on the python object to avoid dispatch overhead
static PyObject * THPVariable_dim(PyObject* self, PyObject* args)
{
HANDLE_TH_ERRORS
@ -181,6 +187,7 @@ static PyObject * THPVariable_dim(PyObject* self, PyObject* args)
END_HANDLE_TH_ERRORS
}
// implemented on the python object to avoid dispatch overhead
static PyObject * THPVariable_numel(PyObject* self, PyObject* args)
{
HANDLE_TH_ERRORS
@ -553,6 +560,8 @@ static PyObject * THPVariable_element_size(PyObject* self, PyObject* args)
END_HANDLE_TH_ERRORS
}
// implemented on the python object bc PyObjects not declarable in native_functions.yaml
// See: ATen/native/README.md for more context
static PyObject * THPVariable_numpy(PyObject* self, PyObject* arg)
{
HANDLE_TH_ERRORS
@ -607,6 +616,7 @@ inline bool dispatch_is_contiguous(Tensor & self, MemoryFormat memory_format) {
return self.is_contiguous(memory_format);
}
// implemented on the python object to avoid dispatch overhead
static PyObject * THPVariable_is_contiguous(PyObject* self_, PyObject* args, PyObject* kwargs)
{
HANDLE_TH_ERRORS
@ -621,6 +631,7 @@ static PyObject * THPVariable_is_contiguous(PyObject* self_, PyObject* args, PyO
END_HANDLE_TH_ERRORS
}
// implemented on the python object to avoid dispatch overhead
static PyObject * THPVariable_item(PyObject* self, PyObject* args)
{
HANDLE_TH_ERRORS
@ -638,6 +649,8 @@ static PyObject * THPVariable_item(PyObject* self, PyObject* args)
END_HANDLE_TH_ERRORS
}
// implemented on the python object bc no support for first class functions in native_functions.yaml
// See: ATen/native/README.md for more context
static PyObject * THPVariable_map_(PyObject* self, PyObject* args, PyObject* kwargs)
{
HANDLE_TH_ERRORS
@ -655,6 +668,8 @@ static PyObject * THPVariable_map_(PyObject* self, PyObject* args, PyObject* kwa
END_HANDLE_TH_ERRORS
}
// implemented on the python object bc no support for first class functions in native_functions.yaml
// See: ATen/native/README.md for more context
static PyObject * THPVariable_map2_(PyObject* self, PyObject* args, PyObject* kwargs)
{
HANDLE_TH_ERRORS
@ -746,6 +761,8 @@ static PyObject * THPVariable_to(PyObject* self, PyObject* args, PyObject* kwarg
END_HANDLE_TH_ERRORS
}
// implemented on the python object b/c arbitrarily nested list not declarable in native_functions.yaml
// See: ATen/native/README.md for more context
static PyObject * THPVariable_tolist(PyObject* self, PyObject* args)
{
HANDLE_TH_ERRORS
@ -830,6 +847,7 @@ static PyObject * TypeError_to_NotImplemented_(PyObject* self, PyObject* args, P
// Any new ops added here should be accompanied with a comment why they are not
// being registered through native_functions.yaml, and be tagged cpp / JIT
PyMethodDef variable_methods[] = {
// These magic methods are all implemented on python object to wrap NotImplementedError
{"__add__", (PyCFunction)(void(*)(void))TypeError_to_NotImplemented_<THPVariable_add>, METH_VARARGS | METH_KEYWORDS, NULL},
{"__radd__", (PyCFunction)(void(*)(void))TypeError_to_NotImplemented_<THPVariable_add>, METH_VARARGS | METH_KEYWORDS, NULL},
{"__iadd__", (PyCFunction)(void(*)(void))TypeError_to_NotImplemented_<THPVariable_add_>, METH_VARARGS | METH_KEYWORDS, NULL},