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

Function IsScalarTensor

oneflow/api/python/autograd/autograd.cpp:41–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39namespace {
40
41bool IsScalarTensor(const one::Tensor& tensor) {
42 const auto& shape = tensor.shape();
43 return shape->elem_cnt() == 1;
44}
45
46// Checks and sets default value for initial gradients based on out_grads
47// If output is the tensor whose size is greater than 1, out_grad's shape must be same as output's.

Callers 1

CheckAndInitOutGradsFunction · 0.70

Calls 2

shapeMethod · 0.45
elem_cntMethod · 0.45

Tested by

no test coverage detected