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

Function TEST_CASE

test/gpu/manage_host_buffer.cpp:37–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35#define MIGRAPHX_HIP_ASSERT(x) (EXPECT(x == hipSuccess))
36
37TEST_CASE(host_same_buffer_copy)
38{
39 migraphx::program p;
40 auto* mm = p.get_main_module();
41 migraphx::shape ss{migraphx::shape::float_type, {4, 2}};
42 auto a = mm->add_parameter("a", ss);
43 auto b = mm->add_parameter("b", ss);
44 auto aa = mm->add_instruction(migraphx::make_op("add"), a, a);
45 auto gpu_out = mm->add_instruction(migraphx::make_op("hip::copy_from_gpu"), aa);
46 auto stream_sync = mm->add_instruction(migraphx::make_op("hip::sync_stream"), gpu_out);
47 auto pass = mm->add_instruction(unary_pass_op{}, stream_sync);
48 auto alloc = mm->add_instruction(
49 migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(ss)}}));
50 auto gpu_in = mm->add_instruction(migraphx::make_op("hip::copy_to_gpu"), pass, alloc);
51 auto aab = mm->add_instruction(migraphx::make_op("add"), gpu_in, b);
52 mm->add_return({aab});
53 migraphx::parameter_map pp;
54 std::vector<float> a_vec(ss.elements(), -1);
55 std::vector<float> b_vec(ss.elements(), 2);
56 pp["a"] = migraphx::argument(ss, a_vec.data());
57 pp["b"] = migraphx::argument(ss, b_vec.data());
58 std::vector<float> gpu_result;
59 migraphx::target gpu_t = migraphx::make_target("gpu");
60 migraphx::compile_options options;
61 options.offload_copy = true;
62 p.compile(gpu_t, options);
63 auto result = p.eval(pp).back();
64 std::vector<float> results_vector(ss.elements(), -1);
65 result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
66 std::vector<float> gold_vec(ss.elements(), 0);
67 EXPECT(migraphx::verify::verify_rms_range(results_vector, gold_vec));
68}
69
70TEST_CASE(arguments_lifetime)
71{

Callers

nothing calls this directly

Calls 15

make_targetFunction · 0.85
verify_rms_rangeFunction · 0.85
register_on_gpuFunction · 0.85
get_main_moduleMethod · 0.80
add_parameterMethod · 0.80
backMethod · 0.80
make_opFunction · 0.50
to_valueFunction · 0.50
argumentClass · 0.50
add_instructionMethod · 0.45
add_returnMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected