Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,31 @@ rust::Vec<float> Engine::infer(const rust::Vec<uint8_t> &input) {
input.size() / (dims.d[0] * dims.d[1] * dims.d[2] * mInputDataTypeSize);

if (calculatedBatchSize < mMinBatchSize) {
throw std::runtime_error("Input is less the minimum batch size: " +
std::to_string(calculatedBatchSize) + " > " +
std::to_string(mMinBatchSize));
throw std::runtime_error(
"Input batch size too small.\n"
"Calculation: input.size() = " + std::to_string(input.size()) +
", dims = [" + std::to_string(dims.d[0]) + ", " +
std::to_string(dims.d[1]) + ", " + std::to_string(dims.d[2]) + "], " +
"mInputDataTypeSize = " + std::to_string(mInputDataTypeSize) + "\n" +
"Computed: " + std::to_string(input.size()) + " / (" +
std::to_string(dims.d[0]) + " * " + std::to_string(dims.d[1]) + " * " +
std::to_string(dims.d[2]) + " * " + std::to_string(mInputDataTypeSize) +
") = " + std::to_string(calculatedBatchSize) + "\n" +
"Which is less than mMinBatchSize = " + std::to_string(mMinBatchSize));
}

if (calculatedBatchSize > mMaxBatchSize) {
throw std::runtime_error("Input is greater than maximum batch size: " +
std::to_string(calculatedBatchSize) + " > " +
std::to_string(mMaxBatchSize));
throw std::runtime_error(
"Input batch size too large.\n"
"Calculation: input.size() = " + std::to_string(input.size()) +
", dims = [" + std::to_string(dims.d[0]) + ", " +
std::to_string(dims.d[1]) + ", " + std::to_string(dims.d[2]) + "], " +
"mInputDataTypeSize = " + std::to_string(mInputDataTypeSize) + "\n" +
"Computed: " + std::to_string(input.size()) + " / (" +
std::to_string(dims.d[0]) + " * " + std::to_string(dims.d[1]) + " * " +
std::to_string(dims.d[2]) + " * " + std::to_string(mInputDataTypeSize) +
") = " + std::to_string(calculatedBatchSize) + "\n" +
"Which is greater than mMaxBatchSize = " + std::to_string(mMaxBatchSize));
}

// Check that vector has enough elements for full input.
Expand Down