From e951f837e43369a71663fe67beee8165397a93bd Mon Sep 17 00:00:00 2001 From: BoarQing Date: Thu, 10 Aug 2023 09:38:30 +0800 Subject: [PATCH] [VITISAI] fix out of bound error on graph with loop (#17065) ### Description Check the bound of the node_get_inputs for out of bound error. ### Motivation and Context Model with loop would encounter this error. Currrent we do not support custom op for loop. So, ideally it would throw an error and fall back to CPU evalution. --- onnxruntime/core/providers/vitisai/imp/node.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/onnxruntime/core/providers/vitisai/imp/node.cc b/onnxruntime/core/providers/vitisai/imp/node.cc index 637fb10ccd..6d65ad4e8c 100644 --- a/onnxruntime/core/providers/vitisai/imp/node.cc +++ b/onnxruntime/core/providers/vitisai/imp/node.cc @@ -21,7 +21,11 @@ vaip_core::DllSafe> node_get_inputs(const Node& node) { } for (auto iter = node.InputEdgesBegin(); iter != node.InputEdgesEnd(); ++iter) { - ret[iter->GetDstArgIndex()].node = &iter->GetNode(); + auto dst_idx = static_cast(iter->GetDstArgIndex()); + if (dst_idx < ret.size()) { + // ignore implicit nodes. + ret[dst_idx].node = &iter->GetNode(); + } } return vaip_core::DllSafe(ret); }