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

Function TEST_CASE

test/quantization.cpp:57–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57TEST_CASE(param_add)
58{
59 auto create_program_float = [](bool add_return = false) {
60 migraphx::program p;
61 auto* mm = p.get_main_module();
62 migraphx::shape s{migraphx::shape::float_type, {2, 3}};
63 auto p1 = mm->add_parameter("x", s);
64 auto p2 = mm->add_parameter("y", s);
65 auto sum = mm->add_instruction(migraphx::make_op("add"), p1, p2);
66 if(add_return)
67 {
68 mm->add_return({sum});
69 }
70
71 return p;
72 };
73
74 auto create_program_half = [](bool add_return = false) {
75 migraphx::program p;
76 auto* mm = p.get_main_module();
77 migraphx::shape s{migraphx::shape::float_type, {2, 3}};
78 auto p1 = mm->add_parameter("x", s);
79 auto p2 = mm->add_parameter("y", s);
80 auto hp1 = mm->add_instruction(migraphx::make_op("convert"), p1);
81 auto hp2 = mm->add_instruction(migraphx::make_op("convert"), p2);
82 auto hs = mm->add_instruction(migraphx::make_op("add"), hp1, hp2);
83 auto fs = mm->add_instruction(
84 migraphx::make_op("convert",
85 {{"target_type", migraphx::to_value(migraphx::shape::float_type)}}),
86 hs);
87 if(add_return)
88 {
89 mm->add_return({fs});
90 }
91 else
92 {
93 mm->add_instruction(migraphx::make_op("identity"), {fs});
94 }
95
96 return p;
97 };
98
99 {
100 auto p1 = create_program_float();
101 auto p2 = create_program_half();
102
103 migraphx::quantize_fp16(p1);
104 EXPECT(p1 == p2);
105 }
106
107 {
108 auto p1 = create_program_float();
109 auto p2 = create_program_half();
110
111 migraphx::quantize_fp16(p1, {"add"});
112 EXPECT(p1 == p2);
113 }
114

Callers

nothing calls this directly

Calls 15

run_passesFunction · 0.85
iotaFunction · 0.85
add_apply_alpha_betaFunction · 0.85
make_targetFunction · 0.85
optimize_prog_int8Function · 0.85
generate_argumentFunction · 0.85
verify_rms_rangeFunction · 0.85
get_main_moduleMethod · 0.80
add_parameterMethod · 0.80
lensMethod · 0.80
backMethod · 0.80

Tested by

no test coverage detected