| 513 | /* ===================== TestJITMlirDimshuffle ===================== */ |
| 514 | |
| 515 | void run_dimshuffle(CompNode cn, TensorShape ishape, const std::vector<int>& pattern) { |
| 516 | set_backend(Backend::MLIR); |
| 517 | auto graph = ComputingGraph::make(); |
| 518 | HostTensorGenerator<> gen; |
| 519 | |
| 520 | auto host_x = gen(ishape, cn); |
| 521 | auto x = opr::Host2DeviceCopy::make(*graph, host_x); |
| 522 | auto y = opr::Dimshuffle::make(x, pattern); |
| 523 | |
| 524 | auto ig_gen = std::make_unique<InternalGraphGenerator>(y.node()->owner_opr()); |
| 525 | |
| 526 | for (auto i : get_rev_topo_order(y)) { |
| 527 | if (!i->template same_type<opr::Host2DeviceCopy>()) { |
| 528 | ig_gen->add_opr(i); |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | auto igraph = ig_gen->generate(); |
| 533 | auto y_jit = JITExecutor::make(igraph, ig_gen->orig_inps()); |
| 534 | |
| 535 | HostTensorND host_y, host_y_jit; |
| 536 | auto func = graph->compile( |
| 537 | {make_callback_copy(y, host_y), make_callback_copy(y_jit, host_y_jit)}); |
| 538 | func->execute(); |
| 539 | |
| 540 | MGB_ASSERT_TENSOR_EQ(host_y, host_y_jit); |
| 541 | } |
| 542 | |
| 543 | void run_dimshuffle_cases(CompNode cn) { |
| 544 | run_dimshuffle(cn, {3, 4, 5}, {2, 0, 1}); |
no test coverage detected