| 55 | } |
| 56 | |
| 57 | TEST_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 |
nothing calls this directly
no test coverage detected