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

Function run_modify_multi_axis_vec_empty_shape

src/opr/test/indexing.cpp:1219–1243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1217
1218template <class Opr>
1219void run_modify_multi_axis_vec_empty_shape(
1220 const TensorShape& ishp, const TensorShape& vshp, const TensorShape& idx0,
1221 const TensorShape& idx1) {
1222 mgb_assert(ishp.ndim >= 4);
1223 mgb_assert(vshp.is_empty() && (idx0.is_empty() || idx1.is_empty()));
1224 using AI = opr::indexing::AxisIndexer;
1225 auto graph = ComputingGraph::make();
1226 HostTensorGenerator<> gen;
1227 HostTensorGenerator<dtype::Int32> gen_idx;
1228 auto host_x = gen(ishp), host_v = gen(vshp);
1229 auto x = opr::Host2DeviceCopy::make(*graph, host_x),
1230 v = opr::Host2DeviceCopy::make(*graph, host_v),
1231 idx_dynamic_shape = opr::MarkDynamicVar::make(
1232 opr::ImmutableTensor::make(*graph, *gen_idx(idx0))),
1233 idx_static_shape = opr::ImmutableTensor::make(*graph, *gen_idx(idx1)),
1234 y = Opr::make(
1235 x, v,
1236 {AI::make_interval(-1, None, None, x.make_scalar(2)),
1237 AI::make_index(1, idx_dynamic_shape),
1238 AI::make_index(2, idx_static_shape)});
1239 HostTensorND host_y;
1240 auto func = graph->compile({make_callback_copy(y, host_y)});
1241 func->execute();
1242 MGB_ASSERT_TENSOR_EQ(*host_x, host_y);
1243}
1244
1245} // namespace
1246

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected