Fix a bug of benchmark_app for binary input filling. (#8960)

This commit is contained in:
Jade Cho 2021-12-07 10:05:17 +09:00 committed by GitHub
parent 42892767f5
commit 7842b636c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,6 +117,20 @@ void fillBlobBinary(Blob::Ptr& inputBlob,
const size_t& inputId, const size_t& inputId,
const size_t& inputSize) { const size_t& inputSize) {
MemoryBlob::Ptr minput = as<MemoryBlob>(inputBlob); MemoryBlob::Ptr minput = as<MemoryBlob>(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) { if (!minput) {
IE_THROW() << "We expect inputBlob to be inherited from MemoryBlob in " IE_THROW() << "We expect inputBlob to be inherited from MemoryBlob in "
"fillBlobBinary, " "fillBlobBinary, "
@ -127,7 +141,7 @@ void fillBlobBinary(Blob::Ptr& inputBlob,
auto minputHolder = minput->wmap(); auto minputHolder = minput->wmap();
auto inputBlobData = minputHolder.as<char*>(); auto inputBlobData = minputHolder.as<char*>();
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) { i++, inputIndex += inputSize) {
inputIndex %= filePaths.size(); inputIndex %= filePaths.size();
@ -142,7 +156,7 @@ void fillBlobBinary(Blob::Ptr& inputBlob,
if (!binaryFile.good()) { if (!binaryFile.good()) {
IE_THROW() << "Can not read " << filePaths[inputIndex]; IE_THROW() << "Can not read " << filePaths[inputIndex];
} }
auto inputSize = inputBlob->size() * sizeof(T) / batchSize; auto inputSize = inputBlob->size() * sizeof(T) / adjBatchSize;
if (fileSize != inputSize) { if (fileSize != inputSize) {
IE_THROW() << "File " << filePaths[inputIndex] << " contains " << std::to_string(fileSize) IE_THROW() << "File " << filePaths[inputIndex] << " contains " << std::to_string(fileSize)
<< " bytes " << " bytes "