MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / TensorSize_AsShape

Function TensorSize_AsShape

oneflow/api/python/framework/size.cpp:182–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182Shape TensorSize_AsShape(PyObject* self) {
183 if (!TensorSize_Check(self)) {
184 PyErr_Format(PyExc_TypeError, "can only convert TensorSize(not \"%s\") to Shape",
185 Py_TYPE(self)->tp_name);
186 return Shape();
187 }
188 int size = TensorSize_length((TensorSize*)self);
189 DimVector dim_vec(size);
190 for (int i = 0; i < size; ++i) {
191 dim_vec[i] = PyLong_AsLongLong(PyTuple_GET_ITEM((TensorSize*)self, i));
192 }
193 return Shape(std::move(dim_vec));
194}
195
196ONEFLOW_API_PYBIND11_MODULE("", m) {
197 if (PyType_Ready(&TensorSize_Type) < 0) { return; }

Callers 3

loadMethod · 0.85
operator()Method · 0.85
operator()Method · 0.85

Calls 3

TensorSize_CheckFunction · 0.85
TensorSize_lengthFunction · 0.85
ShapeClass · 0.50

Tested by

no test coverage detected