diff --git a/onnxruntime/core/mlas/lib/q4_dq_cli.cpp b/onnxruntime/core/mlas/lib/q4_dq_cli.cpp index b994f171c6..5cc66da357 100644 --- a/onnxruntime/core/mlas/lib/q4_dq_cli.cpp +++ b/onnxruntime/core/mlas/lib/q4_dq_cli.cpp @@ -254,13 +254,14 @@ dequantize(const Cli& cli) out.write((const char*)dstbuf.data(), std::streamsize(dstbuf.size()) * sizeof(float)); } else { std::streambuf* buf; + std::ofstream file_output_stream; if (cli.output_file) { - std::ofstream out(cli.output_file, std::ios::out); - if (!out) { + file_output_stream.open(cli.output_file, std::ios::out); + if (file_output_stream.fail()) { std::cerr << "Cannot open output file " << cli.output_file << std::endl; return -1; } - buf = out.rdbuf(); + buf = file_output_stream.rdbuf(); } else { buf = std::cout.rdbuf(); } diff --git a/onnxruntime/python/tools/quantization/matmul_weight4_quantizer.py b/onnxruntime/python/tools/quantization/matmul_weight4_quantizer.py index 44d870bb22..921e02fb69 100644 --- a/onnxruntime/python/tools/quantization/matmul_weight4_quantizer.py +++ b/onnxruntime/python/tools/quantization/matmul_weight4_quantizer.py @@ -189,7 +189,7 @@ class MatMulWeight4Quantizer: # recursive call to take care of sub-graph graph_stack.append(attr.g) kv = {attr.name: self._process_subgraph(graph_stack)} - elif attr.type == onnx.AttributeProto.GRAPH: + elif attr.type == onnx.AttributeProto.GRAPHS: value = [] for subgraph in attr.graphs: # recursive call to take care of sub-graph