Skip to content

Commit d94dc9b

Browse files
author
Uros Petkovic
committed
Adding check for opening file, logs and ORT THROW
1 parent 76a3070 commit d94dc9b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,8 +1083,12 @@ MIGraphXExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_v
10831083
if (dump_model_ops_) {
10841084
std::string model_name = graph_viewer.Name() + ".onnx";
10851085
std::ofstream ofs(model_name, std::ios::binary);
1086+
if (!ofs.is_open()) {
1087+
ORT_THROW("Failed to open file to dump ONNX model: " + model_name);
1088+
}
10861089
ofs.write(onnx_string_buffer.c_str(), onnx_string_buffer.size());
10871090
ofs.close();
1091+
LOGS_DEFAULT(INFO) << "ONNX model dumped to " << model_name;
10881092
}
10891093

10901094
// This is a list of initializers that migraphx considers as constants.
@@ -1336,8 +1340,12 @@ Status MIGraphXExecutionProvider::Compile(const std::vector<FusedNodeAndGraph>&
13361340
if (dump_model_ops_) {
13371341
std::string onnx_name = fused_node.Name() + ".onnx";
13381342
std::ofstream ofs(onnx_name, std::ios::binary);
1343+
if (!ofs.is_open()) {
1344+
ORT_THROW("Failed to open file to dump ONNX model: " + model_name);
1345+
}
13391346
ofs.write(onnx_string_buffer.data(), onnx_string_buffer.size());
13401347
ofs.close();
1348+
LOGS_DEFAULT(INFO) << "ONNX model dumped to " << model_name;
13411349
}
13421350

13431351
std::vector<std::string> input_names, output_names;

0 commit comments

Comments
 (0)