xref: /aosp_15_r20/external/pytorch/torch/csrc/MemoryFormat.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #pragma once
2 
3 #include <torch/csrc/python_headers.h>
4 
5 #include <c10/core/MemoryFormat.h>
6 
7 #include <string>
8 
9 const int MEMORY_FORMAT_NAME_LEN = 64;
10 
11 struct THPMemoryFormat {
12   PyObject_HEAD at::MemoryFormat memory_format;
13   // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
14   char name[MEMORY_FORMAT_NAME_LEN + 1];
15 };
16 
17 extern PyTypeObject THPMemoryFormatType;
18 
THPMemoryFormat_Check(PyObject * obj)19 inline bool THPMemoryFormat_Check(PyObject* obj) {
20   return Py_TYPE(obj) == &THPMemoryFormatType;
21 }
22 
23 PyObject* THPMemoryFormat_New(
24     at::MemoryFormat memory_format,
25     const std::string& name);
26 
27 void THPMemoryFormat_init(PyObject* module);
28