MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / TEST_CASE

Function TEST_CASE

test/eliminate_pad_test.cpp:65–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65TEST_CASE(rewrite_pad)
66{
67 migraphx::module m;
68 size_t img_dim[2] = {2, 2};
69 size_t channels = 1;
70 std::vector<int32_t> input(channels * img_dim[0] * img_dim[1]);
71 std::iota(input.begin(), input.end(), 0);
72
73 migraphx::shape s_img{migraphx::shape::int32_type, {1, channels, img_dim[0], img_dim[1]}};
74 auto l_img = m.add_literal(migraphx::literal{s_img, input});
75 auto padded_img =
76 m.add_instruction(migraphx::make_op("pad", {{"pads", {0, 0, 1, 1, 0, 0, 1, 1}}}), l_img);
77
78 auto l0 = create_im2col(padded_img, channels, m);
79 auto l1 = create_conv(padded_img, channels, m);
80 auto l2 = m.add_instruction(
81 migraphx::make_op("pooling", {{"mode", migraphx::op::pooling_mode::max}}), padded_img);
82 m.add_instruction(migraphx::make_op("identity"), l0, l1, l2);
83
84 auto s0 = l0->get_shape();
85 auto s1 = l1->get_shape();
86 auto s2 = l2->get_shape();
87 run_pass(m);
88 EXPECT(l0->get_shape() == s0);
89 EXPECT(l1->get_shape() == s1);
90 EXPECT(l2->get_shape() == s2);
91 auto op0 = l0->get_operator().to_value();
92 auto om1 = l1->get_operator().to_value();
93 auto om2 = l2->get_operator().to_value();
94
95 EXPECT(op0["padding"].to_vector<std::size_t>() == std::vector<std::size_t>{1, 1, 1, 1});
96 EXPECT(om1["padding"].to_vector<std::size_t>() == std::vector<std::size_t>{1, 1, 1, 1});
97 EXPECT(om2["padding"].to_vector<std::size_t>() == std::vector<std::size_t>{1, 1, 1, 1});
98
99 EXPECT(std::none_of(
100 m.begin(), m.end(), [](const migraphx::instruction& ins) { return ins.name() == "pad"; }));
101}
102
103TEST_CASE(rewrite_pad_im2col_asymmetric)
104{

Callers

nothing calls this directly

Calls 13

iotaFunction · 0.85
create_im2colFunction · 0.70
create_convFunction · 0.70
run_passFunction · 0.70
make_opFunction · 0.50
none_ofFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
add_literalMethod · 0.45
add_instructionMethod · 0.45
get_shapeMethod · 0.45
to_valueMethod · 0.45

Tested by

no test coverage detected