Skip to content

Commit a31fa89

Browse files
committed
Fixing build issue
1 parent be8a4a7 commit a31fa89

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

Tools/ML/MlResponse.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,16 @@ class MlResponse
229229
LOG(fatal) << "Number of input nodes in the model " << mPaths[nModel] << " differs from features per row (" << numInputNodes << " vs " << featuresPerRow << ")";
230230
}
231231

232-
TypeOutputScore* outputPtr = mModels[nModel].template evalModel<TypeOutputScore>(input);
233-
if (outputPtr == nullptr) {
234-
LOG(fatal) << "Batched model evaluation failed for model " << mPaths[nModel];
232+
std::vector<TypeOutputScore> output = mModels[nModel].template evalModel<TypeOutputScore>(input);
233+
const std::size_t expectedOutputSize = nRows * mNClasses;
234+
if (output.size() < expectedOutputSize) {
235+
LOG(fatal) << "Model " << mPaths[nModel] << " returned " << output.size() << " scores, but " << expectedOutputSize << " scores are expected for " << nRows << " rows and " << static_cast<int>(mNClasses) << " classes. Please check your configurables.";
236+
}
237+
if (output.size() > expectedOutputSize) {
238+
// keep only the first scores (e.g. batched probabilities of a multi-output model)
239+
output.resize(expectedOutputSize);
235240
}
236-
return std::vector<TypeOutputScore>{outputPtr, outputPtr + nRows * mNClasses};
241+
return output;
237242
}
238243

239244
/// ML selections

0 commit comments

Comments
 (0)