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

Function apply_on_var_node

imperative/src/impl/ops/fill.cpp:14–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12namespace fill {
13
14auto apply_on_var_node(const OpDef& def, const VarNodeArray& inputs) {
15 auto&& op = static_cast<const Fill&>(def);
16 mgb_assert(inputs.size() == 1);
17 auto comp_node = inputs[0]->comp_node();
18 auto name = op.make_name();
19 DTypeScalar scalar(op.dtype);
20 scalar.set_retain_dtype(op.value);
21 auto graph = inputs[0]->owner_graph();
22 auto scalar_shape = opr::ImmutableTensor::make(*graph, scalar, {name, comp_node});
23 return opr::Broadcast::make(scalar_shape, inputs[0], {name});
24}
25
26std::tuple<SmallVector<LogicalTensorDesc>, bool> infer_output_attrs_fallible(
27 const OpDef& def, const SmallVector<LogicalTensorDesc>& inputs) {

Callers

nothing calls this directly

Calls 7

set_retain_dtypeMethod · 0.80
makeFunction · 0.70
sizeMethod · 0.45
comp_nodeMethod · 0.45
make_nameMethod · 0.45
owner_graphMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected