xref: /aosp_15_r20/external/pytorch/tools/autograd/templates/python_linalg_functions.cpp (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #define TORCH_ASSERT_ONLY_METHOD_OPERATORS
2 // ${generated_comment}
3 
4 #include "torch/csrc/Device.h"
5 #include "torch/csrc/DynamicTypes.h"
6 #include "torch/csrc/Exceptions.h"
7 #include "torch/csrc/autograd/python_linalg_functions.h"
8 #include "torch/csrc/autograd/generated/python_return_types.h"
9 #include "torch/csrc/autograd/python_variable.h"
10 #include "torch/csrc/autograd/utils/wrap_outputs.h"
11 #include "torch/csrc/autograd/utils/python_arg_parsing.h"
12 #include "torch/csrc/utils/pycfunction_helpers.h"
13 #include "torch/csrc/utils/python_arg_parser.h"
14 #include "torch/csrc/utils/structseq.h"
15 
16 #ifndef AT_PER_OPERATOR_HEADERS
17 #include <ATen/Functions.h>
18 #else
19 $ops_headers
20 #endif
21 
22 using at::Tensor;
23 using at::Scalar;
24 using at::ScalarType;
25 using at::MemoryFormat;
26 using at::Generator;
27 using at::IntArrayRef;
28 using at::TensorList;
29 
30 using namespace torch::autograd::utils;
31 
32 namespace torch::autograd {
33 
34 // generated forward declarations start here
35 
36 ${py_forwards}
37 
38 static PyMethodDef linalg_functions[] = {
39   ${py_method_defs}
40   {NULL}
41 };
42 
43 static PyObject* THPLinalgVariableFunctionsModule = NULL;
44 
initLinalgFunctions(PyObject * module)45 void initLinalgFunctions(PyObject* module) {
46   static struct PyModuleDef def = {
47      PyModuleDef_HEAD_INIT,
48      "torch._C._linalg",
49      NULL,
50      -1,
51      linalg_functions
52   };
53   PyObject* linalg = PyModule_Create(&def);
54   THPLinalgVariableFunctionsModule = linalg;
55   if (!linalg) {
56     throw python_error();
57   }
58   // steals a reference to linalg
59   if (PyModule_AddObject(module, "_linalg", linalg) != 0) {
60     throw python_error();
61   }
62 }
63 
64 // generated methods start here
65 
66 ${py_methods}
67 
68 } // namespace torch::autograd
69