diff --git a/onnxruntime/core/graph/contrib_ops/contrib_defs.cc b/onnxruntime/core/graph/contrib_ops/contrib_defs.cc index 09a4a77780..25b1e08bde 100644 --- a/onnxruntime/core/graph/contrib_ops/contrib_defs.cc +++ b/onnxruntime/core/graph/contrib_ops/contrib_defs.cc @@ -3360,6 +3360,7 @@ void RegisterContribSchemas() { "tensor(int16)", "tensor(int32)", "tensor(int64)", + "tensor(bool)", "tensor(uint8)", "tensor(uint16)", "tensor(uint32)", diff --git a/onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.cc b/onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.cc index 6aba51728a..bedc2e9406 100644 --- a/onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.cc +++ b/onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.cc @@ -53,27 +53,6 @@ const std::filesystem::path& GetModelPath(const GraphViewer& graph_viewer) { return main_graph.ModelPath(); } -/* - * Update ep_cache_context attribute of the EP context node with the given engine binary data - */ -void UpdateCtxNodeModelEngineContext(ONNX_NAMESPACE::ModelProto* model_proto, - char* engine_data, - size_t size) { - ONNX_NAMESPACE::GraphProto* graph_proto = model_proto->mutable_graph(); - ONNX_NAMESPACE::NodeProto* node_proto = graph_proto->mutable_node(0); - - for (int i = 0; i < node_proto->attribute_size(); ++i) { - ONNX_NAMESPACE::AttributeProto* attribute_proto = node_proto->mutable_attribute(i); - if (attribute_proto->name() == EP_CACHE_CONTEXT) { - std::string engine_data_str = ""; - if (size > 0) { - engine_data_str.assign(engine_data, size); - } - attribute_proto->set_s(engine_data_str); - } - } -} - /* * Create "EP context node" model where engine information is embedded */ @@ -138,7 +117,8 @@ std::unique_ptr CreateCtxModel(const GraphViewer& graph_viewer, // Create EP context node graph_build.AddNode(fused_subgraph_name, EPCONTEXT_OP, "", inputs, outputs, node_attributes.get(), EPCONTEXT_OP_DOMAIN); - ORT_ENFORCE(graph_build.Resolve().IsOK()); + auto status = graph_build.Resolve(); + ORT_ENFORCE(status.IsOK(), status.ErrorMessage()); return model_build; } @@ -209,17 +189,6 @@ std::string GetCtxModelPath(const std::string& ep_context_file_path, return ctx_model_path; } -/* - * Dump "EP context" model - * - */ -void DumpCtxModel(ONNX_NAMESPACE::ModelProto* model_proto, - const std::string& ctx_model_path) { - std::fstream dump(ctx_model_path, std::ios::out | std::ios::trunc | std::ios::binary); - model_proto->SerializeToOstream(dump); - LOGS_DEFAULT(VERBOSE) << "[TensorRT EP] Dumped " + ctx_model_path; -} - bool IsAbsolutePath(const std::string& path_string) { #ifdef _WIN32 onnxruntime::PathString ort_path_string = onnxruntime::ToPathString(path_string); diff --git a/onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h b/onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h index fb2ceb3bf7..8691d40d5d 100644 --- a/onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h +++ b/onnxruntime/core/providers/tensorrt/onnx_ctx_model_helper.h @@ -41,11 +41,6 @@ std::string GetCtxModelPath(const std::string& ep_context_file_path, const std::string& original_model_path); bool IsAbsolutePath(const std::string& path_string); bool IsRelativePathToParentPath(const std::string& path_string); -void DumpCtxModel(ONNX_NAMESPACE::ModelProto* model_proto, - const std::string& ctx_model_path); -void UpdateCtxNodeModelEngineContext(ONNX_NAMESPACE::ModelProto* model_proto, - char* engine_data, - size_t size); class TensorRTCacheModelHandler { public: diff --git a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc index 1db58b9f6a..b0df60815e 100644 --- a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc +++ b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc @@ -3848,10 +3848,9 @@ Status TensorrtExecutionProvider::CreateNodeComputeInfoFromGraph(const GraphView } } - // dump ep context model + // Give a warning that ep context need to be regenerated if (dump_ep_context_model_ && ep_context_embed_mode_) { - UpdateCtxNodeModelEngineContext(model_proto_.get(), reinterpret_cast(serialized_engine->data()), serialized_engine->size()); - DumpCtxModel(model_proto_.get(), ctx_model_path_); + LOGS_DEFAULT(WARNING) << "Engine was updated during inference due to dynamic input changed change. Please regenerate EP context model."; } context_update = true;