@@ -68,13 +68,18 @@ struct OnnxToOvNetworkBindings {
6868
6969 // For Stateful Model Compilation, the ONNX model includes KV cache (past/present) tensors.
7070 // However, these tensors are internally converted to a stateful representation, which removes them.
71- // To prevent runtime exceptions, we simply continue processing here.
72- if (!matched_names && session_context.enable_causallm &&
73- std::any_of (special_io_names_.begin (), special_io_names_.end (),
74- [&onnx_name](const std::string& name) { return onnx_name.find (name) != std::string::npos; })) {
75- // This case also requires dynamic shape inference, so we'll mark the bindings as dynamic.
76- has_dynamic_io_ = true ;
77- continue ;
71+ // It's also possible that the onnx model does not contain tensors such as beam_idx, whereas our converted
72+ // stateful representation has introduced these new tensors, creating a name mismatch (matched_names=false).
73+ // So, if there is a name mismatch, or the name matches our special io list, we simply continue processing
74+ // here to prevent runtime exceptions.
75+ if (session_context.enable_causallm ) {
76+ if (!matched_names ||
77+ std::any_of (special_io_names_.begin (), special_io_names_.end (),
78+ [&onnx_name](const std::string& name) { return onnx_name.find (name) != std::string::npos; })) {
79+ // This case also requires dynamic shape inference, so we'll mark the bindings as dynamic.
80+ has_dynamic_io_ = true ;
81+ continue ;
82+ }
7883 }
7984
8085 ORT_ENFORCE (matched_names, log_tag,
0 commit comments