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

Function run_mlir_different_shape

src/jit/test/codegen.cpp:187–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187void run_mlir_different_shape(CompNode cn) {
188 set_backend(Backend::MLIR);
189 auto graph = ComputingGraph::make();
190 HostTensorGenerator<dtype::Float32> gen;
191
192 auto run = [&](TensorShape tshp) {
193 auto host_x = gen(tshp, cn);
194 auto x = opr::Host2DeviceCopy::make(*graph, host_x);
195 auto y = x * 2;
196 auto ig_gen = std::make_unique<InternalGraphGenerator>(y.node()->owner_opr());
197
198 for (auto i : get_rev_topo_order(y)) {
199 if (!i->same_type<opr::Host2DeviceCopy>()) {
200 ig_gen->add_opr(i);
201 }
202 }
203
204 auto igraph = ig_gen->generate();
205 auto y_jit = JITExecutor::make(igraph, ig_gen->orig_inps());
206
207 HostTensorND host_y, host_y_jit;
208 auto func = graph->compile(
209 {make_callback_copy(y, host_y), make_callback_copy(y_jit, host_y_jit)});
210 func->execute();
211
212 MGB_ASSERT_TENSOR_EQ(host_y, host_y_jit);
213 };
214
215 run({23, 42});
216 run({16, 31});
217 run({32, 56});
218 run({10});
219}
220
221struct MlirTestOpt {
222 float low;

Callers 1

TESTFunction · 0.85

Calls 10

make_callback_copyFunction · 0.85
makeFunction · 0.50
genFunction · 0.50
runFunction · 0.50
owner_oprMethod · 0.45
nodeMethod · 0.45
add_oprMethod · 0.45
generateMethod · 0.45
compileMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected