| 799 | } |
| 800 | |
| 801 | void 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 | |
| 824 | void StaticInferManagerImpl::register_value_infer( |
| 825 | Tag dest, const ValueInferDesc& desc) { |