Skip to content

Commit 2d7b7cb

Browse files
Yinghai Lufacebook-github-bot
Yinghai Lu
authored andcommitted
Better error message (#3514)
Summary: Give better error message when input tensor is larger than the compiled spec. Adding shape will help on which dimension we got wrong. Documentation: [Optional Fixes #issue] Pull Request resolved: #3514 Test Plan: Please see a detailed explanation of how to fill out the fields in the relevant sections in PULL_REQUEST.md. Differential Revision: D17382475 Pulled By: yinghai fbshipit-source-id: 2ee87b67e7523ea4c3821fc9c8e8ab3b22e633c5
1 parent 486f4e0 commit 2d7b7cb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/Onnxifi/Base.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,18 @@ onnxStatus Graph::setIOAndRun(uint32_t inputsCount,
157157
}
158158

159159
if (inOnnxTensorSize > inPhPtr->getType()->size()) {
160+
std::stringstream ss;
161+
for (const auto j : inOnnxTensorDims) {
162+
ss << j << ", ";
163+
}
164+
ss << " vs ";
165+
auto sizes = inPhPtr->getType()->dims();
166+
for (const auto j : sizes) {
167+
ss << j << ", ";
168+
}
160169
LOG(ERROR) << "Input tensor is too large: " << inOnnxTensorSize << " vs "
161-
<< inPhPtr->getType()->size() << ": " << inOnnxTensor.name;
170+
<< inPhPtr->getType()->size() << ": " << inOnnxTensor.name
171+
<< ", shape: " << ss.str();
162172
return ONNXIFI_STATUS_INVALID_SHAPE;
163173
}
164174

0 commit comments

Comments
 (0)