MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / make_scalar_shape

Function make_scalar_shape

imperative/src/impl/transformations/scalar.cpp:14–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12static std::unordered_map<Typeinfo*, ScalarRule> scalar_rules;
13
14ValueRef make_scalar_shape(CompNode device) {
15 HostTensorND scalar_shape(device, {1}, dtype::Int32());
16 scalar_shape.ptr<dt_int32>()[0] = 1;
17 return imperative::apply(
18 CreateTensor(CreateTensor::Const, device, scalar_shape.layout()),
19 HostStorage::make(scalar_shape.storage()))[0];
20}
21
22bool is_scalar_shape(ValueRef shape) {
23 // may have performance issue

Callers 3

reduce_ruleFunction · 0.85
reshape_ruleFunction · 0.85
broadcast_ruleFunction · 0.85

Calls 5

CreateTensorClass · 0.85
storageMethod · 0.80
applyFunction · 0.50
makeFunction · 0.50
layoutMethod · 0.45

Tested by

no test coverage detected