From ffd907116838ec4b47daf051c08f28f1bed258e6 Mon Sep 17 00:00:00 2001 From: Hariharan Seshadri Date: Fri, 5 Apr 2019 12:50:58 -0700 Subject: [PATCH] expose graph node name returning non-zero status code (#714) * Initial commit --- .../InferenceTest.cs | 6 +++++- onnxruntime/core/framework/sequential_executor.cc | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs index 30141cf5d7..91167c92bc 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs @@ -152,7 +152,11 @@ namespace Microsoft.ML.OnnxRuntime.Tests var tensor = new DenseTensor(inputData, new int[] { 1, 3 }); container.Add(NamedOnnxValue.CreateFromTensor("data_0", tensor)); var ex = Assert.Throws(() => session.Run(container)); - Assert.Equal("[ErrorCode:Fail] X num_dims does not match W num_dims. X: {1,3} W: {64,3,3,3}", ex.Message); + Assert.True( + !string.IsNullOrEmpty(ex.Message) && + ex.Message.StartsWith("[ErrorCode:Fail]") && + ex.Message.Contains("X num_dims does not match W num_dims. X: {1,3} W: {64,3,3,3}") + ); session.Dispose(); } diff --git a/onnxruntime/core/framework/sequential_executor.cc b/onnxruntime/core/framework/sequential_executor.cc index 6b050e68c9..e5bd2c55cf 100644 --- a/onnxruntime/core/framework/sequential_executor.cc +++ b/onnxruntime/core/framework/sequential_executor.cc @@ -6,6 +6,7 @@ #include #include #include +#include #include "core/common/common.h" #include "core/common/logging/logging.h" #include "core/framework/allocation_planner.h" @@ -112,7 +113,18 @@ Status SequentialExecutor::Execute(const SessionState& session_state, kernel_begin_time = session_state.Profiler().StartTime(); } - ORT_RETURN_IF_ERROR(p_op_kernel->Compute(&op_kernel_context)); + + const auto& compute_status = p_op_kernel->Compute(&op_kernel_context); + if (!compute_status.IsOK()) { + std::ostringstream ss; + ss << "Non-zero status code returned while running Node: " << + p_op_kernel->Node().Name() << + " Status Message: " << + compute_status.ErrorMessage(); + const auto msg_string = ss.str(); + LOGS(logger, ERROR) << msg_string; + return Status(compute_status.Category(), compute_status.Code(), msg_string); + } if (f_profiler_enabled) { session_state.Profiler().EndTimeAndRecordEvent(profiling::NODE_EVENT,