| 185 | } |
| 186 | |
| 187 | void 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 | |
| 221 | struct MlirTestOpt { |
| 222 | float low; |