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

Function apply_on_var_node

imperative/src/impl/subgraph_detail.cpp:15–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace subgraph_detail {
14
15VarNodeArray apply_on_var_node(const OpDef& def, const VarNodeArray& inputs) {
16 SmallVector<LogicalTensorDesc> input_descs;
17 for (auto&& input : inputs) {
18 input_descs.push_back({TensorLayout{input->dtype()}, input->comp_node()});
19 }
20 auto apply_functor = [&](const std::shared_ptr<OpDef>& op,
21 const VarNodeArray& inputs, size_t nr_outputs) {
22 op->set_scope(def.scope());
23 return OpDef::apply_on_var_node(*op, inputs);
24 };
25 auto const_functor = [&](const TensorPtr& value) {
26 return opr::ImmutableTensor::make(*inputs[0]->owner_graph(), value->get_value())
27 .node();
28 };
29 auto subgraph = def.trait()->make_forward_graph(def, input_descs);
30 auto outputs = subgraph.apply<VarNode*>(inputs, apply_functor, const_functor);
31 return outputs;
32}
33
34std::tuple<SmallVector<LogicalTensorDesc>, bool> infer_output_attrs_fallible(
35 const OpDef& def, const SmallVector<LogicalTensorDesc>& inputs) {

Callers

nothing calls this directly

Calls 11

set_scopeMethod · 0.80
scopeMethod · 0.80
make_forward_graphMethod · 0.80
makeFunction · 0.70
push_backMethod · 0.45
dtypeMethod · 0.45
comp_nodeMethod · 0.45
nodeMethod · 0.45
owner_graphMethod · 0.45
get_valueMethod · 0.45
traitMethod · 0.45

Tested by

no test coverage detected