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

Function TEST_CASE

test/promote_literals_test.cpp:48–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48TEST_CASE(promote_only)
49{
50 migraphx::program p0;
51 {
52 auto* mm0 = p0.get_main_module();
53
54 // create batch submodules
55 auto create_submodule = [&](std::size_t batch_size, const std::string& module_name) {
56 auto* submod = p0.create_module(module_name);
57 migraphx::shape sm_shape{migraphx::shape::float_type, {batch_size, 4}};
58 auto sm_input = submod->add_parameter("data", sm_shape);
59 migraphx::shape lit_s{migraphx::shape{migraphx::shape::float_type, {1}}};
60 auto literal_ins = submod->add_literal(migraphx::literal{lit_s, {6}});
61 auto broadcast_lit =
62 submod->add_instruction(migraphx::make_op("multibroadcast"), literal_ins, sm_input);
63 auto add_ins =
64 submod->add_instruction(migraphx::make_op("add"), sm_input, broadcast_lit);
65 submod->add_return({add_ins});
66 return submod;
67 };
68 auto* dim1 = create_submodule(1, "dim_1");
69 auto* dim2 = create_submodule(2, "dim_2");
70 auto* dim3 = create_submodule(3, "dim_3");
71 auto* dim4 = create_submodule(4, "dim_4");
72
73 migraphx::shape s{migraphx::shape::float_type, {{1, 4}, {4, 4}}};
74 auto input0 = mm0->add_parameter("data", s);
75 std::vector<migraphx::shape> sub_shapes = {};
76 sub_shapes.push_back(migraphx::shape{migraphx::shape::float_type, {{1, 4}, {4, 4}}});
77 migraphx::shape out_attr = migraphx::shape{sub_shapes};
78 auto sm_ins = mm0->add_instruction(
79 migraphx::make_op("select_module",
80 {{"output_dyn_shapes", migraphx::to_value(out_attr)}}),
81 {input0},
82 {dim1, dim2, dim3, dim4});
83 auto ret =
84 mm0->add_instruction(migraphx::make_op("get_tuple_elem", {{"index", 0}}), sm_ins);
85 mm0->add_return({ret});
86 }
87 run_promote(p0);
88
89 migraphx::program p1;
90 {
91 auto* mm1 = p1.get_main_module();
92 migraphx::shape lit_s{migraphx::shape{migraphx::shape::float_type, {1}}};
93 auto literal_ins3 = mm1->add_literal(migraphx::literal{lit_s, {6}});
94 auto literal_ins2 = mm1->add_literal(migraphx::literal{lit_s, {6}});
95 auto literal_ins1 = mm1->add_literal(migraphx::literal{lit_s, {6}});
96 auto literal_ins0 = mm1->add_literal(migraphx::literal{lit_s, {6}});
97
98 // create batch submodules
99 auto create_submodule = [&](std::size_t batch_size,
100 migraphx::instruction_ref lit,
101 const std::string& module_name) {
102 auto* submod = p1.create_module(module_name);
103 migraphx::shape sm_shape{migraphx::shape::float_type, {batch_size, 4}};
104 auto sm_input = submod->add_parameter("data", sm_shape);
105 auto broadcast_lit =

Callers

nothing calls this directly

Calls 12

run_promoteFunction · 0.85
run_promote_and_ecsFunction · 0.85
get_main_moduleMethod · 0.80
add_parameterMethod · 0.80
insert_parameterMethod · 0.80
make_opFunction · 0.50
to_valueFunction · 0.50
create_moduleMethod · 0.45
add_literalMethod · 0.45
add_instructionMethod · 0.45
add_returnMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected