From 4aa4ca1502e002f4ef794b84c4561b1f58774edf Mon Sep 17 00:00:00 2001 From: Pranav Sharma Date: Tue, 23 Jul 2019 18:47:46 -0700 Subject: [PATCH] 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. --- onnxruntime/core/session/inference_session.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index c4ed8be620..98cbb126cb 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -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 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();