xref: /aosp_15_r20/external/pytorch/torch/csrc/Layout.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1*da0073e9SAndroid Build Coastguard Worker #pragma once
2*da0073e9SAndroid Build Coastguard Worker 
3*da0073e9SAndroid Build Coastguard Worker #include <torch/csrc/python_headers.h>
4*da0073e9SAndroid Build Coastguard Worker 
5*da0073e9SAndroid Build Coastguard Worker #include <ATen/Layout.h>
6*da0073e9SAndroid Build Coastguard Worker 
7*da0073e9SAndroid Build Coastguard Worker #include <string>
8*da0073e9SAndroid Build Coastguard Worker 
9*da0073e9SAndroid Build Coastguard Worker const int LAYOUT_NAME_LEN = 64;
10*da0073e9SAndroid Build Coastguard Worker 
11*da0073e9SAndroid Build Coastguard Worker struct THPLayout {
12*da0073e9SAndroid Build Coastguard Worker   PyObject_HEAD at::Layout layout;
13*da0073e9SAndroid Build Coastguard Worker   // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
14*da0073e9SAndroid Build Coastguard Worker   char name[LAYOUT_NAME_LEN + 1];
15*da0073e9SAndroid Build Coastguard Worker };
16*da0073e9SAndroid Build Coastguard Worker 
17*da0073e9SAndroid Build Coastguard Worker extern PyTypeObject THPLayoutType;
18*da0073e9SAndroid Build Coastguard Worker 
THPLayout_Check(PyObject * obj)19*da0073e9SAndroid Build Coastguard Worker inline bool THPLayout_Check(PyObject* obj) {
20*da0073e9SAndroid Build Coastguard Worker   return Py_TYPE(obj) == &THPLayoutType;
21*da0073e9SAndroid Build Coastguard Worker }
22*da0073e9SAndroid Build Coastguard Worker 
23*da0073e9SAndroid Build Coastguard Worker PyObject* THPLayout_New(at::Layout layout, const std::string& name);
24*da0073e9SAndroid Build Coastguard Worker 
25*da0073e9SAndroid Build Coastguard Worker void THPLayout_init(PyObject* module);
26