@@ -28,6 +28,17 @@ PyObject* THPMemoryFormat_repr(THPMemoryFormat* self) {
28
28
return THPUtils_packString (self->name );
29
29
}
30
30
31
+ PyObject* THPMemoryFormat_reduce (PyObject* _self, PyObject* noargs) {
32
+ auto * self = (THPMemoryFormat*)_self;
33
+ return THPUtils_packString (self->name );
34
+ }
35
+
36
+ // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,cppcoreguidelines-avoid-non-const-global-variables,modernize-avoid-c-arrays)
37
+ static PyMethodDef THPMemoryFormat_methods[] = {
38
+ {" __reduce__" , THPMemoryFormat_reduce, METH_NOARGS, nullptr },
39
+ {nullptr } /* Sentinel */
40
+ };
41
+
31
42
PyTypeObject THPMemoryFormatType = {
32
43
PyVarObject_HEAD_INIT (nullptr , 0 ) " torch.memory_format" , /* tp_name */
33
44
sizeof (THPMemoryFormat), /* tp_basicsize */
@@ -55,7 +66,7 @@ PyTypeObject THPMemoryFormatType = {
55
66
0 , /* tp_weaklistoffset */
56
67
nullptr , /* tp_iter */
57
68
nullptr , /* tp_iternext */
58
- nullptr , /* tp_methods */
69
+ THPMemoryFormat_methods , /* tp_methods */
59
70
nullptr , /* tp_members */
60
71
nullptr , /* tp_getset */
61
72
nullptr , /* tp_base */
0 commit comments