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

Function check_is_shape_of

src/opr/impl/tensor_manip.cpp:22–44  ·  view source on GitHub ↗

check whether shp is GetVarShape(a)

Source from the content-addressed store, hash-verified

20using OptionalAxis = megdnn::param::OptionalAxisV1;
21//! check whether shp is GetVarShape(a)
22bool 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

Callers 1

makeMethod · 0.85

Calls 10

infer_valueMethod · 0.80
owner_oprMethod · 0.45
nodeMethod · 0.45
sizeMethod · 0.45
inputMethod · 0.45
paramMethod · 0.45
owner_graphMethod · 0.45
get_infer_typeMethod · 0.45
infer_shapeMethod · 0.45
eq_shapeMethod · 0.45

Tested by

no test coverage detected