xref: /aosp_15_r20/external/pytorch/tools/autograd/templates/python_fft_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_fft_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/autograd/generated/variable_factories.h"
13 #include "torch/csrc/utils/out_types.h"
14 #include "torch/csrc/utils/pycfunction_helpers.h"
15 #include "torch/csrc/utils/python_arg_parser.h"
16 #include "torch/csrc/utils/structseq.h"
17 #include "torch/csrc/utils/device_lazy_init.h"
18 
19 #include <ATen/core/Tensor.h>
20 
21 #ifndef AT_PER_OPERATOR_HEADERS
22 #include <ATen/Functions.h>
23 #else
24 $ops_headers
25 #endif
26 
27 using at::Tensor;
28 using at::Device;
29 using at::Layout;
30 using at::Scalar;
31 using at::ScalarType;
32 using at::Backend;
33 using at::OptionalDeviceGuard;
34 using at::DeviceGuard;
35 using at::TensorOptions;
36 using at::IntArrayRef;
37 using at::Generator;
38 using at::TensorList;
39 using at::Dimname;
40 using at::DimnameList;
41 
42 using torch::utils::check_out_type_matches;
43 using namespace torch::autograd::utils;
44 
45 namespace torch::autograd {
46 
47 // generated forward declarations start here
48 
49 ${py_forwards}
50 
51 static PyMethodDef fft_functions[] = {
52   ${py_method_defs}
53   {NULL}
54 };
55 
56 static PyObject* THPFFTVariableFunctionsModule = NULL;
57 
initFFTFunctions(PyObject * module)58 void initFFTFunctions(PyObject* module) {
59   static struct PyModuleDef def = {
60      PyModuleDef_HEAD_INIT,
61      "torch._C._fft",
62      NULL,
63      -1,
64      fft_functions
65   };
66   PyObject* fft = PyModule_Create(&def);
67   THPFFTVariableFunctionsModule = fft;
68   if (!fft) {
69     throw python_error();
70   }
71   // steals a reference to fft
72   if (PyModule_AddObject(module, "_fft", fft) != 0) {
73     throw python_error();
74   }
75 }
76 
77 // generated methods start here
78 
79 ${py_methods}
80 
81 } // namespace torch::autograd
82