| 1638 | #if MGB_JIT_MLIR |
| 1639 | |
| 1640 | void run_mlir(CompNode cn) { |
| 1641 | set_backend(Backend::MLIR); |
| 1642 | |
| 1643 | HostTensorGenerator<> gen; |
| 1644 | auto host_x0 = gen({23, 42}, cn), host_x1 = gen({23, 1}, cn), |
| 1645 | host_x2 = gen({1, 42}, cn), host_x3 = gen({23, 42}, cn), |
| 1646 | host_x4 = gen({1, 42}, cn), host_x5 = gen({23, 1}, cn); |
| 1647 | |
| 1648 | auto make_dst = [&](ComputingGraph& graph) { |
| 1649 | auto a = opr::Host2DeviceCopy::make(graph, host_x0), |
| 1650 | b = opr::Host2DeviceCopy::make(graph, host_x1), |
| 1651 | c = opr::Host2DeviceCopy::make(graph, host_x2), |
| 1652 | d = opr::Host2DeviceCopy::make(graph, host_x3), |
| 1653 | e = opr::Host2DeviceCopy::make(graph, host_x4); |
| 1654 | return a + opr::max(b, c) + opr::max(d, e); |
| 1655 | }; |
| 1656 | HostTensorND host_y1, host_y2; |
| 1657 | auto funcs = make_func_pair(host_y1, host_y2, make_dst, 2); |
| 1658 | |
| 1659 | funcs.first->execute(); |
| 1660 | funcs.second->execute(); |
| 1661 | MGB_ASSERT_TENSOR_EQ(host_y1, host_y2); |
| 1662 | |
| 1663 | JITExecutor* jit; |
| 1664 | unpack_vector(find_oprs<JITExecutor>(*funcs.second), jit); |
| 1665 | ASSERT_EQ(0u, find_oprs<opr::Elemwise>(*funcs.second).size()); |
| 1666 | ASSERT_EQ(5u, jit->input().size()); |
| 1667 | } |
| 1668 | |
| 1669 | TEST(TestJITExecutor, TestJITMlirFusion) { |
| 1670 | run_mlir(CompNode::load("cpu0")); |
no test coverage detected