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

Function TEST_CASE

test/gpu/codegen_literal.cpp:57–84  ·  view source on GitHub ↗

This test ensures that the codegen path doesn't round up literals, otherwise there are accuracy differences compared to ref. The values being passed in are 0.5 * (1/0.00787402), and after rounding must equal 63, not 64.

Source from the content-addressed store, hash-verified

55// The values being passed in are 0.5 * (1/0.00787402),
56// and after rounding must equal 63, not 64.
57TEST_CASE(mul_literal_round_test)
58{
59
60 migraphx::program p;
61 auto* mm = p.get_main_module();
62 migraphx::shape s0{migraphx::shape::float_type, {1}};
63 auto l0 = mm->add_parameter("a", s0);
64 auto l1 = mm->add_literal(1 / 0.00787402f);
65
66 auto mul = mm->add_instruction(migraphx::make_op("mul"), l0, l1);
67 auto round = mm->add_instruction(migraphx::make_op("nearbyint"), mul);
68
69 mm->add_return({round});
70
71 migraphx::parameter_map m;
72 std::vector<float> a = {0.5f};
73
74 m["a"] = migraphx::argument{s0, a.data()};
75 std::vector<float> ref_result;
76 migraphx::target ref_t = migraphx::make_target("ref");
77 run_prog(p, ref_t, m, ref_result);
78
79 std::vector<float> gpu_result;
80 migraphx::target gpu_t = migraphx::make_target("gpu");
81 run_prog(p, gpu_t, m, gpu_result);
82
83 EXPECT(migraphx::verify::verify_rms_range(gpu_result, ref_result));
84}
85
86int main(int argc, const char* argv[]) { test::run(argc, argv); }

Callers

nothing calls this directly

Calls 10

make_targetFunction · 0.85
verify_rms_rangeFunction · 0.85
get_main_moduleMethod · 0.80
add_parameterMethod · 0.80
run_progFunction · 0.70
make_opFunction · 0.50
add_literalMethod · 0.45
add_instructionMethod · 0.45
add_returnMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected