| 104 | } |
| 105 | |
| 106 | double time_program(const context& ictx, |
| 107 | program p, |
| 108 | const std::unordered_map<std::string, double>& fill_map, |
| 109 | int bundle, |
| 110 | int nruns) |
| 111 | { |
| 112 | std::vector<migraphx::context> ctx_vec = {ictx}; |
| 113 | auto& gctx = any_cast<migraphx::gpu::context>(ctx_vec.front()); |
| 114 | auto* mm = p.get_main_module(); |
| 115 | mm->finalize(ctx_vec); |
| 116 | auto in_shapes = p.get_parameter_shapes(); |
| 117 | std::unordered_map<std::string, migraphx::argument> param_map; |
| 118 | unsigned long seed = 0; |
| 119 | for(const auto& [name, shape] : in_shapes) |
| 120 | { |
| 121 | std::string id = ""; |
| 122 | if(shape.type() != migraphx::shape::tuple_type) |
| 123 | id = shape.type_string() + migraphx::shape::to_sizes_string({shape.as_standard()}); |
| 124 | |
| 125 | if(contains(fill_map, id)) |
| 126 | param_map[name] = to_gpu(fill_argument(shape, fill_map.at(id))); |
| 127 | else |
| 128 | param_map[name] = to_gpu(generate_argument(shape, seed++, random_mode::random)); |
| 129 | } |
| 130 | auto run = [&] { p.eval_with_context(ctx_vec, param_map); }; |
| 131 | return time_loop(gctx, bundle, nruns, run); |
| 132 | } |
| 133 | |
| 134 | } // namespace gpu |
| 135 | } // namespace MIGRAPHX_INLINE_NS |
no test coverage detected