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

Function TensorSize_NewFromShape

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

Source from the content-addressed store, hash-verified

170PyObject* TensorSize_New(Py_ssize_t len) { return TensorSize_Type.tp_alloc(&TensorSize_Type, len); }
171
172PyObject* TensorSize_NewFromShape(const Shape& size) {
173 PyObjectPtr self(TensorSize_New(size.NumAxes()));
174 if (self.get()) {
175 for (int i = 0; i < size.NumAxes(); ++i) {
176 PyTuple_SET_ITEM(self.get(), i, PyLong_FromLongLong(size.At(i)));
177 }
178 }
179 return self.release();
180}
181
182Shape TensorSize_AsShape(PyObject* self) {
183 if (!TensorSize_Check(self)) {

Callers 2

PyTensorObject_sizeFunction · 0.85
cast_implMethod · 0.85

Calls 5

TensorSize_NewFunction · 0.85
NumAxesMethod · 0.45
getMethod · 0.45
AtMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected