check whether shp is GetVarShape(a)
| 20 | using OptionalAxis = megdnn::param::OptionalAxisV1; |
| 21 | //! check whether shp is GetVarShape(a) |
| 22 | bool check_is_shape_of(SymbolVar shp, SymbolVar a) { |
| 23 | #if MGB_BUILD_SLIM_SERVING |
| 24 | return false; |
| 25 | #else |
| 26 | auto op = shp.node()->owner_opr(); |
| 27 | if (op->same_type<GetVarShape>() && op->input().size() == 1 && |
| 28 | op->input()[0] == a.node() && |
| 29 | op->cast_final<GetVarShape>().param().axis == OptionalAxis::INVALID_AXIS) { |
| 30 | return true; |
| 31 | } |
| 32 | using namespace cg::static_infer; |
| 33 | auto&& mgr = a.node()->owner_graph()->static_infer_manager(); |
| 34 | if ((mgr.get_infer_type(shp.node()).value & InferType::CONST) && |
| 35 | (mgr.get_infer_type(a.node()).shape & InferType::CONST)) { |
| 36 | auto&& a_shp = mgr.infer_shape(a.node()); |
| 37 | auto&& shp_val = mgr.infer_value(shp.node()); |
| 38 | TensorShape shp_shp; |
| 39 | cg::copy_tensor_value_to_shape(shp_shp, shp_val); |
| 40 | return a_shp.eq_shape(shp_shp); |
| 41 | } |
| 42 | return false; |
| 43 | #endif |
| 44 | } |
| 45 | |
| 46 | #if !MGB_BUILD_SLIM_SERVING |
| 47 | // return x such that shape_of(var) == x |
no test coverage detected