Repository: microsoft/onnxruntime
File: onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc (C++)

Code before:
        auto tensor_shape = input_tensor[i]->Shape();
        for (int j = 1; j < tensor_shape->dim_size(); ++j) {
          input_shapes.push_back(tensor_shape->dim(j).dim_value());
        }
      }
      model_cache_file = model_cache_path_ / (mxr_filename_prefix + make_hash(input_shapes) + ".mxr");
    }

    // map parameter input name to index
    std::unordered_map<std::string, std::size_t> input_name_index;
    const auto& input_defs = fused_node.InputDefs();
    input_name_index.reserve(input_defs.size());
    for (std::size_t i = 0; i < input_defs.size(); ++i) {
      input_name_index[input_defs[i]->Name()] = i;
    }

    auto model = graph_body_viewer.CreateModel(*GetLogger());
    auto model_proto = model->ToProto();
    graph_body_viewer.ToProto(*model_proto->mutable_graph(), true, true);
    model_proto->set_ir_version(ONNX_NAMESPACE::Version::IR_VERSION);
    std::string onnx_string_buffer;
    model_proto->SerializeToString(onnx_string_buffer);

    if (dump_model_ops_) {
      std::string onnx_name = fused_node.Name() + ".onnx";
      std::ofstream ofs(onnx_name, std::ios::binary);
      if (!ofs.is_open()) {
        ORT_THROW("Failed to open file to dump ONNX model: " + model_name);
      }
      ofs.write(onnx_string_buffer.data(), onnx_string_buffer.size());
      ofs.close();
      LOGS_DEFAULT(INFO) << "ONNX model dumped to " << model_name;
    }

    std::vector<std::string> input_names, output_names;
    no_input_shape = no_input_shape || get_input_output_names(graph_body_viewer, input_names, output_names);

    // by parsing the model_proto, create a program corresponding to
    // the input fused_node
    migraphx::program prog;

    if (!no_input_shape) {
      if (!load_precompiled_model(prog, model_cache_file)) {
        LOGS_DEFAULT(VERBOSE) << "No input shapes detected quantizing model";
#ifndef ENABLE_TRAINING_CORE
#ifdef HAVE_MIGRAPHX_API_ONNX_OPTIONS_SET_EXTERNAL_DATA_PATH
        options.set_external_data_path(model_path_.parent_path().string());
#endif
#endif
        prog = migraphx::parse_onnx_buffer(onnx_string_buffer, options);
        migraphx::program_parameters quant_params;

Review comment (suggestion):
There seems to be a small typo here. The variable should probably be `onnx_name` instead of `model_name` to match the variable defined a few lines above.

Code after:
        auto tensor_shape = input_tensor[i]->Shape();
        for (int j = 1; j < tensor_shape->dim_size(); ++j) {
          input_shapes.push_back(tensor_shape->dim(j).dim_value());
        }
      }
      model_cache_file = model_cache_path_ / (mxr_filename_prefix + make_hash(input_shapes) + ".mxr");
    }

    // map parameter input name to index
    std::unordered_map<std::string, std::size_t> input_name_index;
    const auto& input_defs = fused_node.InputDefs();
    input_name_index.reserve(input_defs.size());
    for (std::size_t i = 0; i < input_defs.size(); ++i) {
      input_name_index[input_defs[i]->Name()] = i;
    }

    auto model = graph_body_viewer.CreateModel(*GetLogger());
    auto model_proto = model->ToProto();
    graph_body_viewer.ToProto(*model_proto->mutable_graph(), true, true);
    model_proto->set_ir_version(ONNX_NAMESPACE::Version::IR_VERSION);
    std::string onnx_string_buffer;
    model_proto->SerializeToString(onnx_string_buffer);

    if (dump_model_ops_) {
      std::string onnx_name = fused_node.Name() + ".onnx";
      std::ofstream ofs(onnx_name, std::ios::binary);
      if (!ofs.is_open()) {
        ORT_THROW("Failed to open file to dump ONNX model: " + onnx_name);
      }
      ofs.write(onnx_string_buffer.data(), onnx_string_buffer.size());
      ofs.close();
      LOGS_DEFAULT(INFO) << "ONNX model dumped to " << onnx_name;
    }

    std::vector<std::string> input_names, output_names;
    no_input_shape = no_input_shape || get_input_output_names(graph_body_viewer, input_names, output_names);

    // by parsing the model_proto, create a program corresponding to
    // the input fused_node
    migraphx::program prog;

    if (!no_input_shape) {
      if (!load_precompiled_model(prog, model_cache_file)) {
        LOGS_DEFAULT(VERBOSE) << "No input shapes detected quantizing model";
#ifndef ENABLE_TRAINING_CORE
#ifdef HAVE_MIGRAPHX_API_ONNX_OPTIONS_SET_EXTERNAL_DATA_PATH
        options.set_external_data_path(model_path_.parent_path().string());
#endif
#endif
        prog = migraphx::parse_onnx_buffer(onnx_string_buffer, options);
        migraphx::program_parameters quant_params;