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

Function ParseArrayToTensor

oneflow/api/python/functional/indexing.cpp:128–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128void ParseArrayToTensor(PyObject* object,
129 const std::shared_ptr<vm::EagerBlobObject>& eager_blob_object) {
130 const DataType dtype = eager_blob_object->data_type();
131 const int ndims = eager_blob_object->shape().NumAxes();
132 DimVector strides(ndims);
133 int64_t size = 1;
134 for (int i = ndims - 1; i >= 0; --i) {
135 strides[i] = size;
136 size *= eager_blob_object->shape().At(i);
137 }
138 RecursiveParseAndAssign(object, eager_blob_object->mut_dptr<char>(), ndims, 0,
139 eager_blob_object->shape(), strides, dtype);
140}
141
142Shape InferArraySizes(PyObject* object) {
143 DimVector sizes;

Callers 1

ConvertToIndexingTensorFunction · 0.85

Calls 5

RecursiveParseAndAssignFunction · 0.85
data_typeMethod · 0.45
NumAxesMethod · 0.45
shapeMethod · 0.45
AtMethod · 0.45

Tested by

no test coverage detected