Add tensor(bool) to valid EPContext input type (Zcode model error)

This commit is contained in:
Jingyan Wang 2025-01-22 22:28:07 +00:00
parent 41958dc16c
commit 44818f12e8
4 changed files with 5 additions and 41 deletions

View file

@ -3360,6 +3360,7 @@ void RegisterContribSchemas() {
"tensor(int16)",
"tensor(int32)",
"tensor(int64)",
"tensor(bool)",
"tensor(uint8)",
"tensor(uint16)",
"tensor(uint32)",

View file

@ -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<Model> 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);

View file

@ -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:

View file

@ -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<char*>(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;