| 357 | } |
| 358 | |
| 359 | program load() |
| 360 | { |
| 361 | program p; |
| 362 | if(is_test) |
| 363 | { |
| 364 | p = test_gemm(); |
| 365 | } |
| 366 | else |
| 367 | { |
| 368 | if(file_type.empty()) |
| 369 | { |
| 370 | file_type = get_file_type(file); |
| 371 | } |
| 372 | std::cout << "Reading: " << file << std::endl; |
| 373 | if(file_type == "onnx") |
| 374 | { |
| 375 | p = parse_onnx(file, get_onnx_options()); |
| 376 | } |
| 377 | else if(file_type == "tf") |
| 378 | { |
| 379 | p = parse_tf(file, get_tf_options()); |
| 380 | } |
| 381 | else if(file_type == "json") |
| 382 | { |
| 383 | file_options options; |
| 384 | options.format = "json"; |
| 385 | p = migraphx::load(file, options); |
| 386 | } |
| 387 | #ifdef MIGRAPHX_ENABLE_PYTHON |
| 388 | else if(file_type == "py") |
| 389 | { |
| 390 | p = migraphx::load_py(file); |
| 391 | } |
| 392 | #endif |
| 393 | else if(file_type == "migraphx") |
| 394 | { |
| 395 | p = migraphx::load(file); |
| 396 | } |
| 397 | } |
| 398 | if(trim > 0) |
| 399 | { |
| 400 | trim_module(*p.get_main_module(), trim, trim_size); |
| 401 | } |
| 402 | // Remove unused variable when exporting to cpp |
| 403 | if(output_type == "cpp") |
| 404 | migraphx::run_passes(*p.get_main_module(), {migraphx::dead_code_elimination{}}); |
| 405 | if(optimize) |
| 406 | { |
| 407 | migraphx::run_passes(*p.get_main_module(), |
| 408 | { |
| 409 | migraphx::eliminate_identity{}, |
| 410 | migraphx::dead_code_elimination{}, |
| 411 | migraphx::simplify_algebra{}, |
| 412 | migraphx::dead_code_elimination{}, |
| 413 | migraphx::simplify_reshapes{}, |
| 414 | migraphx::dead_code_elimination{}, |
| 415 | migraphx::propagate_constant{}, |
| 416 | migraphx::dead_code_elimination{}, |
no test coverage detected