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

Function TEST_CASE

test/ref/roialign.cpp:34–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32#include <test.hpp>
33
34TEST_CASE(roialign_out_of_bound_test)
35{
36 auto create_program = [](const std::string& trans_mode = "half_pixel") {
37 migraphx::program p;
38 auto* mm = p.get_main_module();
39 migraphx::shape x_s{migraphx::shape::float_type, {1, 1, 10, 10}};
40 std::vector<float> x_vec = {
41 0.2764, 0.7150, 0.1958, 0.3416, 0.4638, 0.0259, 0.2963, 0.6518, 0.4856, 0.7250,
42 0.9637, 0.0895, 0.2919, 0.6753, 0.0234, 0.6132, 0.8085, 0.5324, 0.8992, 0.4467,
43 0.3265, 0.8479, 0.9698, 0.2471, 0.9336, 0.1878, 0.4766, 0.4308, 0.3400, 0.2162,
44 0.0206, 0.1720, 0.2155, 0.4394, 0.0653, 0.3406, 0.7724, 0.3921, 0.2541, 0.5799,
45 0.4062, 0.2194, 0.4473, 0.4687, 0.7109, 0.9327, 0.9815, 0.6320, 0.1728, 0.6119,
46 0.3097, 0.1283, 0.4984, 0.5068, 0.4279, 0.0173, 0.4388, 0.0430, 0.4671, 0.7119,
47 0.1011, 0.8477, 0.4726, 0.1777, 0.9923, 0.4042, 0.1869, 0.7795, 0.9946, 0.9689,
48 0.1366, 0.3671, 0.7011, 0.6234, 0.9867, 0.5585, 0.6985, 0.5609, 0.8788, 0.9928,
49 0.5697, 0.8511, 0.6711, 0.9406, 0.8751, 0.7496, 0.1650, 0.1049, 0.1559, 0.2514,
50 0.7012, 0.4056, 0.7879, 0.3461, 0.0415, 0.2998, 0.5094, 0.3727, 0.5482, 0.0502};
51
52 migraphx::shape roi_s{migraphx::shape::float_type, {3, 4}};
53 std::vector<float> roi_vec = {0, 0, 9.99, 9.99, 0, 5, 4, 9, 5, 5, 9.9, 9.9};
54
55 migraphx::shape ind_s{migraphx::shape::int64_type, {3}};
56 std::vector<int64_t> ind_vec = {0, 0, 0};
57
58 auto x = mm->add_literal(migraphx::literal(x_s, x_vec));
59 auto roi = mm->add_literal(migraphx::literal(roi_s, roi_vec));
60 auto ind = mm->add_literal(migraphx::literal(ind_s, ind_vec));
61 auto r =
62 mm->add_instruction(migraphx::make_op("roialign",
63 {{"coordinate_transformation_mode", trans_mode},
64 {"spatial_scale", 5.0},
65 {"output_height", 1},
66 {"output_width", 1},
67 {"sampling_ratio", 1}}),
68 x,
69 roi,
70 ind);
71 mm->add_return({r});
72 return p;
73 };
74
75 {
76 auto p = create_program("half_pixel");
77 p.compile(migraphx::make_target("ref"));
78 auto result = p.eval({}).back();
79 std::vector<float> results_vector;
80 result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
81 std::vector<float> gold = {0.0f, 0.0f, 0.0f};
82
83 EXPECT(migraphx::verify::verify_rms_range(results_vector, gold));
84 }
85}
86
87TEST_CASE(roialign_test)
88{

Callers

nothing calls this directly

Calls 15

make_targetFunction · 0.85
verify_rms_rangeFunction · 0.85
get_main_moduleMethod · 0.80
backMethod · 0.80
create_programFunction · 0.70
literalClass · 0.50
make_opFunction · 0.50
add_literalMethod · 0.45
add_instructionMethod · 0.45
add_returnMethod · 0.45
compileMethod · 0.45
evalMethod · 0.45

Tested by

no test coverage detected