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

Function test_dot_horiz

test/simplify_algebra_test.cpp:2908–2938  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2906}
2907
2908static void test_dot_horiz(migraphx::shape::type_t type, const std::string& dot_type)
2909{
2910 auto s = migraphx::shape{type, {3, 2, 2}};
2911 migraphx::module m1;
2912 {
2913 auto input = m1.add_parameter("input", s);
2914 auto a = m1.add_literal(migraphx::generate_literal(s, 0));
2915 auto b = m1.add_literal(migraphx::generate_literal(s, 1));
2916 auto x = m1.add_instruction(migraphx::make_op(dot_type), input, a);
2917 auto y = m1.add_instruction(migraphx::make_op(dot_type), input, b);
2918 auto sum = m1.add_instruction(migraphx::make_op("add"), x, y);
2919 m1.add_instruction(pass_op{}, sum);
2920 }
2921 run_pass(m1);
2922
2923 migraphx::module m2;
2924 {
2925 auto input = m2.add_parameter("input", s);
2926 auto a = m2.add_literal(migraphx::generate_literal(s, 0));
2927 auto b = m2.add_literal(migraphx::generate_literal(s, 1));
2928 auto concat = m2.add_instruction(migraphx::make_op("concat", {{"axis", 2}}), a, b);
2929 auto dot = m2.add_instruction(migraphx::make_op(dot_type), input, concat);
2930 auto x = m2.add_instruction(
2931 migraphx::make_op("slice", {{"axes", {2}}, {"starts", {0}}, {"ends", {2}}}), dot);
2932 auto y = m2.add_instruction(
2933 migraphx::make_op("slice", {{"axes", {2}}, {"starts", {2}}, {"ends", {4}}}), dot);
2934 auto sum = m2.add_instruction(migraphx::make_op("add"), x, y);
2935 m2.add_instruction(pass_op{}, sum);
2936 }
2937 EXPECT(m1.sort() == m2.sort());
2938}
2939
2940TEST_CASE(simplify_dot_horiz) { test_dot_horiz(migraphx::shape::int32_type, "dot"); }
2941

Callers 1

TEST_CASEFunction · 0.85

Calls 7

generate_literalFunction · 0.85
add_parameterMethod · 0.80
run_passFunction · 0.70
make_opFunction · 0.50
add_literalMethod · 0.45
add_instructionMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected