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

Method register_shape_infer

src/core/impl/graph/static_infer_impl.cpp:801–822  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

799}
800
801void StaticInferManagerImpl::register_shape_infer(
802 Tag dest, const ShapeInferDesc& desc) {
803 mgb_assert(dest->owner_opr() == m_register_allowed_opr);
804 for (auto&& i : desc.deps)
805 mgb_assert(dest->owner_graph() == i.dest->owner_graph());
806
807 auto&& t = get_tag_trait_container(dest);
808 mgb_assert(!t.shape, "shape desc already inserted");
809 auto ptr = m_mem_pool_shape_trait.alloc_unique(dest);
810 ptr->init(desc, this);
811 if (ptr->infer_type() == InferType::CONST &&
812 !dest->contain_flag(VarNode::Flag::VOLATILE_CONTENT)) {
813 // infer const shapes immediately
814 auto r = ptr->infer(false, false);
815 mgb_assert(r && r->m_shape);
816 dest->shape(r->shape());
817 dest->m_allow_shape_change = false;
818 t.shape = m_mem_pool_const_shape_trait.alloc(dest);
819 } else {
820 t.shape = ptr.release();
821 }
822}
823
824void StaticInferManagerImpl::register_value_infer(
825 Tag dest, const ValueInferDesc& desc) {

Calls 10

alloc_uniqueMethod · 0.80
infer_typeMethod · 0.80
owner_oprMethod · 0.45
owner_graphMethod · 0.45
initMethod · 0.45
contain_flagMethod · 0.45
inferMethod · 0.45
shapeMethod · 0.45
allocMethod · 0.45
releaseMethod · 0.45