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

Function run_mlir

src/jit/test/fusion.cpp:1640–1667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1638#if MGB_JIT_MLIR
1639
1640void 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
1669TEST(TestJITExecutor, TestJITMlirFusion) {
1670 run_mlir(CompNode::load("cpu0"));

Callers 1

TESTFunction · 0.70

Calls 8

maxFunction · 0.85
make_func_pairFunction · 0.85
unpack_vectorFunction · 0.85
genFunction · 0.50
makeFunction · 0.50
executeMethod · 0.45
sizeMethod · 0.45
inputMethod · 0.45

Tested by

no test coverage detected