Relax shape validation checks. Log a warning instead of returning an error. (#1476)

* Mention OrtCreateSessionFromArray in C API doc

* Relax shape validation checks. Log a warning instead of returning an error.
This commit is contained in:
Pranav Sharma 2019-07-23 18:47:46 -07:00 committed by GitHub
parent c5f2f0f15b
commit 4aa4ca1502
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -566,9 +566,12 @@ common::Status InferenceSession::CheckShapes(const std::string& input_name,
auto input_shape_sz = input_shape.NumDimensions();
auto expected_shape_sz = expected_shape.NumDimensions();
if (input_shape_sz != expected_shape_sz) {
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "Invalid rank for input: ",
input_name,
" Got: ", input_shape_sz, " Expected: ", expected_shape_sz);
std::ostringstream ostr;
ostr << "Invalid rank for input: " << input_name
<< " Got: " << input_shape_sz << " Expected: " << expected_shape_sz
<< " Please fix either the inputs or the model.";
LOGS(*session_logger_, WARNING) << ostr.str();
return Status::OK();
}
std::vector<int> invalid_dim_indices;
@ -588,7 +591,8 @@ common::Status InferenceSession::CheckShapes(const std::string& input_name,
int idx = invalid_dim_indices[i];
ostr << " index: " << idx << " Got: " << input_shape[idx] << " Expected: " << expected_shape[idx] << "\n";
}
return Status(ONNXRUNTIME, INVALID_ARGUMENT, ostr.str());
ostr << " Please fix either the inputs or the model.";
LOGS(*session_logger_, WARNING) << ostr.str();
}
return Status::OK();