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

Function TEST_CASE

test/ref/add.cpp:34–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32#include <test.hpp>
33
34TEST_CASE(add_broadcast_test)
35{
36 migraphx::program p;
37 auto* mm = p.get_main_module();
38 migraphx::shape a_shape{migraphx::shape::float_type, {2, 2, 3}};
39 std::vector<float> a_data{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
40 migraphx::shape b_shape{migraphx::shape::float_type, {2, 2}};
41 std::vector<float> b_data{0, -1, -2, -3};
42 uint64_t axis = 0;
43 auto l1 = mm->add_literal(migraphx::literal{a_shape, a_data});
44 auto l2 = mm->add_literal(migraphx::literal{b_shape, b_data});
45 auto l3 = mm->add_instruction(
46 migraphx::make_op("broadcast", {{"axis", axis}, {"out_lens", l1->get_shape().lens()}}), l2);
47 mm->add_instruction(migraphx::make_op("add"), l1, l3);
48 p.compile(migraphx::make_target("ref"));
49 auto result = p.eval({}).back();
50 EXPECT(result.get_shape().packed());
51 std::vector<float> results_vector(12);
52 result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
53 std::vector<float> gold = {0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8};
54 EXPECT(migraphx::verify::verify_rms_range(results_vector, gold));
55}
56
57TEST_CASE(add_multibroadcast_test)
58{

Callers

nothing calls this directly

Calls 15

make_targetFunction · 0.85
verify_rms_rangeFunction · 0.85
iotaFunction · 0.85
get_main_moduleMethod · 0.80
lensMethod · 0.80
backMethod · 0.80
add_parameterMethod · 0.80
create_programFunction · 0.70
make_opFunction · 0.50
argumentClass · 0.50
literalClass · 0.50
quantize_fp16Function · 0.50

Tested by

no test coverage detected