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

Function get_var_shape_rule

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

Source from the content-addressed store, hash-verified

211}
212
213ValueRefList get_var_shape_rule(
214 const GetVarShape& get_var_shape, Span<ValueRef> inputs, Span<bool> inputs_mask,
215 const Type<ScalarValue>& scalar_type) {
216 bool all_scalar = true;
217 mgb_assert(inputs.size() >= 1);
218 for (auto&& input_mask : inputs_mask) {
219 if (!input_mask) {
220 all_scalar = false;
221 }
222 }
223 if (all_scalar) {
224 auto device = inputs[0].device();
225 auto storage = HostStorage::make(*device);
226 // storage->ensure_size(1);
227 return imperative::apply(
228 CreateTensor(
229 CreateTensor::Const, *device, dtype::Int32(), ValueShape{0}),
230 storage);
231 } else {
232 return imperative::apply(get_var_shape, inputs);
233 }
234}
235
236ValueRefList reshape_rule(
237 const Reshape& reshape, Span<ValueRef> inputs, Span<bool> inputs_mask,

Callers

nothing calls this directly

Calls 5

CreateTensorClass · 0.85
makeFunction · 0.50
applyFunction · 0.50
sizeMethod · 0.45
deviceMethod · 0.45

Tested by

no test coverage detected