diff --git a/samples/cpp/benchmark_app/inputs_filling.cpp b/samples/cpp/benchmark_app/inputs_filling.cpp index d50567caf98..0e777d7fdbc 100644 --- a/samples/cpp/benchmark_app/inputs_filling.cpp +++ b/samples/cpp/benchmark_app/inputs_filling.cpp @@ -117,6 +117,20 @@ void fillBlobBinary(Blob::Ptr& inputBlob, const size_t& inputId, const size_t& inputSize) { MemoryBlob::Ptr minput = as(inputBlob); + auto adjBatchSize = batchSize; + + // Check layout + std::stringstream ss; + auto tensorDesc = inputBlob->getTensorDesc(); + ss << tensorDesc.getLayout(); + auto layout = ss.str(); + std::size_t batchIndex = layout.find("N"); + if (batchIndex == std::string::npos) { + adjBatchSize = 1; + } else if (tensorDesc.getDims().at(batchIndex) != batchSize) { + adjBatchSize = tensorDesc.getDims().at(batchIndex); + } + if (!minput) { IE_THROW() << "We expect inputBlob to be inherited from MemoryBlob in " "fillBlobBinary, " @@ -127,7 +141,7 @@ void fillBlobBinary(Blob::Ptr& inputBlob, auto minputHolder = minput->wmap(); auto inputBlobData = minputHolder.as(); - for (size_t i = 0ULL, inputIndex = requestId * batchSize * inputSize + inputId; i < batchSize; + for (size_t i = 0ULL, inputIndex = requestId * adjBatchSize * inputSize + inputId; i < adjBatchSize; i++, inputIndex += inputSize) { inputIndex %= filePaths.size(); @@ -142,7 +156,7 @@ void fillBlobBinary(Blob::Ptr& inputBlob, if (!binaryFile.good()) { IE_THROW() << "Can not read " << filePaths[inputIndex]; } - auto inputSize = inputBlob->size() * sizeof(T) / batchSize; + auto inputSize = inputBlob->size() * sizeof(T) / adjBatchSize; if (fileSize != inputSize) { IE_THROW() << "File " << filePaths[inputIndex] << " contains " << std::to_string(fileSize) << " bytes "