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

Function TEST_CASE

test/multi_target/multitarget_test.cpp:161–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161TEST_CASE(multitarget_compile_cpu_gpu)
162{
163 migraphx::program p;
164 auto* mm = p.get_main_module();
165 auto* cpu_mod = p.create_module("cpu_mod");
166 auto s = migraphx::shape{migraphx::shape::float_type, {8}};
167 auto x_cpu = cpu_mod->add_parameter("cpu_x", s);
168 auto y_cpu = cpu_mod->add_parameter("cpu_y", s);
169 auto cpu_add = cpu_mod->add_instruction(migraphx::make_op("add"), x_cpu, y_cpu);
170 cpu_mod->add_return({cpu_add});
171
172 auto* gpu_mod = p.create_module("gpu_mod");
173 auto x_gpu = gpu_mod->add_parameter("gpu_x", s);
174 auto y_gpu = gpu_mod->add_parameter("gpu_y", s);
175 auto gpu_add = gpu_mod->add_instruction(migraphx::make_op("add"), x_gpu, y_gpu);
176 gpu_mod->add_return({gpu_add});
177
178 auto x_param = mm->add_parameter("x", s);
179 auto y_param = mm->add_parameter("y", s);
180 auto z_param = mm->add_parameter("z", s);
181 auto cpu_ins = mm->add_instruction(
182 migraphx::make_op("run_on_target", {{"target_id", 1}}), {x_param, y_param}, {cpu_mod});
183 auto cpu_ins_0 =
184 mm->add_instruction(migraphx::make_op("get_tuple_elem", {{"index", 0}}), cpu_ins);
185 auto gpu_ins = mm->add_instruction(
186 migraphx::make_op("run_on_target", {{"target_id", 0}}), {cpu_ins_0, z_param}, {gpu_mod});
187 auto gpu_ins_0 =
188 mm->add_instruction(migraphx::make_op("get_tuple_elem", {{"index", 0}}), gpu_ins);
189
190 mm->add_return({gpu_ins_0});
191 migraphx::compile_options gpu_opts;
192 gpu_opts.offload_copy = true;
193 p.compile({migraphx::make_target("gpu"), migraphx::make_target("cpu")}, {gpu_opts});
194 EXPECT(check_compiled_program(p, {migraphx::make_target("gpu"), migraphx::make_target("cpu")}));
195 migraphx::parameter_map params;
196 params["x"] = migraphx::fill_argument(s, 1);
197 params["y"] = migraphx::fill_argument(s, 2);
198 params["z"] = migraphx::fill_argument(s, 3);
199 auto result = p.eval(params).back();
200 auto gold = migraphx::fill_argument(s, 6);
201 EXPECT(gold == result);
202}
203
204TEST_CASE(single_target_multi_compile)
205{

Callers

nothing calls this directly

Calls 15

make_targetFunction · 0.85
check_compiled_programFunction · 0.85
fill_argumentFunction · 0.85
generate_argumentFunction · 0.85
get_main_moduleMethod · 0.80
add_parameterMethod · 0.80
backMethod · 0.80
make_opFunction · 0.50
literalClass · 0.50
argumentClass · 0.50
to_stringFunction · 0.50
to_valueFunction · 0.50

Tested by

no test coverage detected