diff --git a/onnxruntime/core/graph/graph.cc b/onnxruntime/core/graph/graph.cc index 8ae7535da4413..5ca7f9902a5cb 100644 --- a/onnxruntime/core/graph/graph.cc +++ b/onnxruntime/core/graph/graph.cc @@ -4277,6 +4277,16 @@ bool Graph::AddControlEdge(NodeIndex src_node_index, NodeIndex dst_node_index) { const ONNX_NAMESPACE::GraphProto& Graph::ToGraphProto() { if (!GraphProtoSyncNeeded()) { + for (int tensor_idx = 0; tensor_idx < graph_proto_->initializer_size(); ++tensor_idx) { + auto tensor = graph_proto_->mutable_initializer(tensor_idx); + if (utils::HasExternalDataInMemory(*tensor)) { + std::unique_ptr full_init; + ORT_THROW_IF_ERROR(utils::GetTensorProtoWithDataIfInMemory(*tensor, full_init)); + tensor->clear_data_location(); + tensor->clear_external_data(); + tensor->set_raw_data(full_init->raw_data()); + } + } return *graph_proto_; } diff --git a/onnxruntime/core/providers/nv_tensorrt_rtx/nv_execution_provider.cc b/onnxruntime/core/providers/nv_tensorrt_rtx/nv_execution_provider.cc index 286db9070766d..1c18f87b2e43e 100644 --- a/onnxruntime/core/providers/nv_tensorrt_rtx/nv_execution_provider.cc +++ b/onnxruntime/core/providers/nv_tensorrt_rtx/nv_execution_provider.cc @@ -1649,7 +1649,10 @@ SubGraphCollection_t NvExecutionProvider::GetSupportedList(SubGraphCollection_t SetAllGraphInputs(graph_build); } - ORT_ENFORCE(graph_build.Resolve().IsOK()); + auto status = graph_build.Resolve(); + if (!status.IsOK()) { + ORT_THROW_IF_ERROR(ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Graph resolve failed with error: " + status.ErrorMessage())); + } // Add parent graph output to the subgraph int i = 0;