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

Function PyScalarTensorCheck

oneflow/api/python/functional/common.cpp:174–181  ·  view source on GitHub ↗

Scalar Tensor

Source from the content-addressed store, hash-verified

172
173// Scalar Tensor
174bool PyScalarTensorCheck(PyObject* obj) {
175 if (!LazyMode::is_enabled() && PyTensor_Check(obj)) {
176 const auto& tensor = PyTensor_Unpack(obj);
177 return tensor->shape()->size() == 0
178 && IsTriviallyCopyableDataType(tensor->dtype()->data_type());
179 }
180 return false;
181}
182
183Scalar PyUnpackScalarTensor(PyObject* obj) {
184 if (PyBoolScalarTensorCheck(obj)) {

Callers 2

ObjectAs<Scalar>Method · 0.85
TypeCheckMethod · 0.85

Calls 7

PyTensor_CheckFunction · 0.85
is_enabledFunction · 0.50
sizeMethod · 0.45
shapeMethod · 0.45
data_typeMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected