| 35 | #define MIGRAPHX_HIP_ASSERT(x) (EXPECT(x == hipSuccess)) |
| 36 | |
| 37 | TEST_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 | |
| 70 | TEST_CASE(arguments_lifetime) |
| 71 | { |
nothing calls this directly
no test coverage detected