From 3d51c8f0d7e3bb07ff4799c2d74df6435d95fe4c Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Wed, 27 May 2026 22:54:00 +0200 Subject: [PATCH 1/2] check for numInputNodes == numCachedIndices in init() --- Tools/ML/MlResponse.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tools/ML/MlResponse.h b/Tools/ML/MlResponse.h index 75da1b8decb..32678222256 100644 --- a/Tools/ML/MlResponse.h +++ b/Tools/ML/MlResponse.h @@ -151,8 +151,13 @@ class MlResponse void init(bool enableOptimizations = false, int threads = 0) { uint8_t counterModel{0}; + const int numCachedIndices = static_cast(mCachedIndices.size()); for (const auto& path : mPaths) { mModels[counterModel].initModel(path, enableOptimizations, threads); + const int numInputNodes = mModels[counterModel].getNumInputNodes(); + if (numInputNodes != numCachedIndices) { + LOG(fatal) << "Number of input nodes in the model " << path << " is different from the number of input features indices (" << numInputNodes << " vs " << numCachedIndices << ")"; + } ++counterModel; } } From ed3ba51152488af4af01bde49fdea804357f0f29 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Fri, 5 Jun 2026 11:54:40 +0200 Subject: [PATCH 2/2] return in case of failed size equality check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Vít Kučera <26327373+vkucera@users.noreply.github.com> --- Tools/ML/MlResponse.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Tools/ML/MlResponse.h b/Tools/ML/MlResponse.h index 32678222256..4b5d976cb77 100644 --- a/Tools/ML/MlResponse.h +++ b/Tools/ML/MlResponse.h @@ -157,6 +157,7 @@ class MlResponse const int numInputNodes = mModels[counterModel].getNumInputNodes(); if (numInputNodes != numCachedIndices) { LOG(fatal) << "Number of input nodes in the model " << path << " is different from the number of input features indices (" << numInputNodes << " vs " << numCachedIndices << ")"; + return; } ++counterModel; }