Skip to content

Commit a3fe8e0

Browse files
lubynetsvkucera
andauthored
[Tools] MlResponse: assure equality of number of checked features to that in the .onnx file (#16424)
Co-authored-by: Vít Kučera <26327373+vkucera@users.noreply.github.com>
1 parent 7daab4f commit a3fe8e0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Tools/ML/MlResponse.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,14 @@ class MlResponse
151151
void init(bool enableOptimizations = false, int threads = 0)
152152
{
153153
uint8_t counterModel{0};
154+
const int numCachedIndices = static_cast<int>(mCachedIndices.size());
154155
for (const auto& path : mPaths) {
155156
mModels[counterModel].initModel(path, enableOptimizations, threads);
157+
const int numInputNodes = mModels[counterModel].getNumInputNodes();
158+
if (numInputNodes != numCachedIndices) {
159+
LOG(fatal) << "Number of input nodes in the model " << path << " is different from the number of input features indices (" << numInputNodes << " vs " << numCachedIndices << ")";
160+
return;
161+
}
156162
++counterModel;
157163
}
158164
}

0 commit comments

Comments
 (0)