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

Function run_multi_axis_vec_empty_shape

src/opr/test/indexing.cpp:1193–1216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1191
1192template <class Opr>
1193void run_multi_axis_vec_empty_shape(
1194 const TensorShape& ishp, const TensorShape& idx0, const TensorShape& idx1,
1195 const TensorShape& tshp) {
1196 mgb_assert(ishp.ndim >= 4);
1197 mgb_assert(idx0.is_empty() || idx1.is_empty());
1198 using AI = opr::indexing::AxisIndexer;
1199 auto graph = ComputingGraph::make();
1200 HostTensorGenerator<> gen;
1201 HostTensorGenerator<dtype::Int32> gen_idx;
1202 auto host_x = gen(ishp);
1203 auto x = opr::Host2DeviceCopy::make(*graph, host_x),
1204 idx_dynamic_shape = opr::MarkDynamicVar::make(
1205 opr::ImmutableTensor::make(*graph, *gen_idx(idx0))),
1206 idx_static_shape = opr::ImmutableTensor::make(*graph, *gen_idx(idx1)),
1207 y = Opr::make(
1208 x, {AI::make_interval(-1, None, None, x.make_scalar(2)),
1209 AI::make_index(1, idx_dynamic_shape),
1210 AI::make_index(2, idx_static_shape)});
1211 HostTensorND host_y;
1212 auto func = graph->compile({make_callback_copy(y, host_y)});
1213 func->execute();
1214 ASSERT_TRUE(host_y.shape().is_empty());
1215 MGB_ASSERT_SHAPE_EQ(host_y.shape(), tshp);
1216}
1217
1218template <class Opr>
1219void run_modify_multi_axis_vec_empty_shape(

Callers

nothing calls this directly

Calls 8

make_callback_copyFunction · 0.85
makeFunction · 0.70
genFunction · 0.50
is_emptyMethod · 0.45
make_scalarMethod · 0.45
compileMethod · 0.45
executeMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected