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

Method init_output_static_infer_desc

imperative/src/impl/opr_utility.cpp:63–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void InputCallback::init_output_static_infer_desc() {
64 using namespace cg::static_infer;
65 if (m_use_static_shape) {
66 auto&& mgr = owner_graph()->static_infer_manager();
67 auto infer_shape = [this](TensorShape& dest, const InpVal&) {
68 dest = m_output_shape;
69 return true;
70 };
71 mgr.register_shape_infer(output(0), {SourceType::CONSTANT, {}, infer_shape});
72 } else {
73 if (m_output_shape.ndim) {
74 // Write this shape to static infer manager. The effect is
75 // that infer_shape_fallible() will return a non-empty shape
76 // while get_infer_type() remains NO_DESC. Most places check
77 // infer type before relying on inferred shape so things
78 // won't break. Memory optimizer however, deliberately omits
79 // infer type check so it will be able to use this shape for hint.
80 auto* var = output(0);
81 var->shape(m_output_shape);
82 auto&& mgr = cg::ComputingGraphImpl::downcast(owner_graph())
83 ->static_infer_manager_impl();
84 auto* handle = mgr.get_tag_handler_for_shape(var);
85 handle->sync_from_var();
86 }
87 }
88}
89
90cg::OperatorNodeBase::NodeProp* InputCallback::do_make_node_prop() const {
91 NodeProp* prop = Super::do_make_node_prop();

Callers 2

updateMethod · 0.45
MiniGraphMethod · 0.45

Calls 7

sync_from_varMethod · 0.80
register_shape_inferMethod · 0.45
shapeMethod · 0.45
layoutMethod · 0.45
proxy_to_default_cpuMethod · 0.45
register_value_inferMethod · 0.45

Tested by

no test coverage detected