| 61 | } |
| 62 | |
| 63 | void 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 | |
| 90 | cg::OperatorNodeBase::NodeProp* InputCallback::do_make_node_prop() const { |
| 91 | NodeProp* prop = Super::do_make_node_prop(); |
no test coverage detected