| 249 | |
| 250 | template <typename tag, int arity> |
| 251 | void run_mlir_mode(CompNode cn) { |
| 252 | set_backend(Backend::MLIR); |
| 253 | auto graph = ComputingGraph::make(); |
| 254 | auto opt = get_mode_opt(tag::mode); |
| 255 | HostTensorGenerator<dtype::Float32, RandomDistribution::UNIFORM> gen( |
| 256 | opt.low, opt.high); |
| 257 | |
| 258 | SmallVector<std::shared_ptr<HostTensorND>> hosts; |
| 259 | VarNodeArray input_vars; |
| 260 | for (int i = 0; i < arity; i++) { |
| 261 | hosts.push_back(gen({2323, 4242}, cn)); |
| 262 | input_vars.push_back(opr::Host2DeviceCopy::make(*graph, hosts[i]).node()); |
| 263 | } |
| 264 | |
| 265 | auto y = opr::Elemwise::make(input_vars, tag::mode); |
| 266 | |
| 267 | auto ig_gen = std::make_unique<InternalGraphGenerator>(y.node()->owner_opr()); |
| 268 | |
| 269 | for (auto i : get_rev_topo_order(y)) { |
| 270 | if (!i->template same_type<opr::Host2DeviceCopy>()) { |
| 271 | ig_gen->add_opr(i); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | auto igraph = ig_gen->generate(); |
| 276 | auto y_jit = JITExecutor::make(igraph, ig_gen->orig_inps()); |
| 277 | |
| 278 | HostTensorND host_y, host_y_jit; |
| 279 | auto func = graph->compile( |
| 280 | {make_callback_copy(y, host_y), make_callback_copy(y_jit, host_y_jit)}); |
| 281 | func->execute(); |
| 282 | |
| 283 | MGB_ASSERT_TENSOR_NEAR(host_y, host_y_jit, opt.maxerr); |
| 284 | } |
| 285 | #endif |
| 286 | } // anonymous namespace |
| 287 |
nothing calls this directly
no test coverage detected