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

Function run_mlir_broadcast

src/jit/test/codegen.cpp:152–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152void run_mlir_broadcast(CompNode cn) {
153 set_backend(Backend::MLIR);
154 auto graph = ComputingGraph::make();
155 HostTensorGenerator<dtype::Float32> gen;
156
157 auto host_x0 = gen({10, 20, 5, 6}, cn), host_x1 = gen({1, 20, 1, 1}, cn),
158 host_x2 = gen({10, 1, 5, 1}, cn), host_x3 = gen({10, 1, 1, 1}, cn);
159
160 auto a = opr::Host2DeviceCopy::make(*graph, host_x0),
161 b = opr::Host2DeviceCopy::make(*graph, host_x1),
162 c = opr::Host2DeviceCopy::make(*graph, host_x2),
163 d = opr::Host2DeviceCopy::make(*graph, host_x3);
164
165 auto y = opr::Elemwise::make({a, b, c}, opr::Elemwise::Mode::FUSE_MUL_ADD3) +
166 opr::Elemwise::make({d}, opr::Elemwise::Mode::ABS) - 0.3f;
167
168 auto ig_gen = std::make_unique<InternalGraphGenerator>(y.node()->owner_opr());
169
170 for (auto i : get_rev_topo_order(y)) {
171 if (!i->same_type<opr::Host2DeviceCopy>()) {
172 ig_gen->add_opr(i);
173 }
174 }
175
176 auto igraph = ig_gen->generate();
177 auto y_jit = JITExecutor::make(igraph, ig_gen->orig_inps());
178
179 HostTensorND host_y, host_y_jit;
180 auto func = graph->compile(
181 {make_callback_copy(y, host_y), make_callback_copy(y_jit, host_y_jit)});
182 func->execute();
183
184 MGB_ASSERT_TENSOR_EQ(host_y, host_y_jit);
185}
186
187void run_mlir_different_shape(CompNode cn) {
188 set_backend(Backend::MLIR);

Callers 1

TESTFunction · 0.85

Calls 9

make_callback_copyFunction · 0.85
makeFunction · 0.50
genFunction · 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