From bf3c32166d26c4bafaafe63d5de5f5dfec6494a9 Mon Sep 17 00:00:00 2001 From: Tracy Sharpe <42477615+tracysh@users.noreply.github.com> Date: Sun, 14 Jun 2020 15:10:22 -0700 Subject: [PATCH] fix optional input/outputs (#4229) --- onnxruntime/core/framework/sequential_executor.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/onnxruntime/core/framework/sequential_executor.cc b/onnxruntime/core/framework/sequential_executor.cc index 055eb1608f..66168b171e 100644 --- a/onnxruntime/core/framework/sequential_executor.cc +++ b/onnxruntime/core/framework/sequential_executor.cc @@ -61,7 +61,7 @@ static void CalculateTotalOutputSizes(OpKernelContextInternal* op_kernel_context ORT_UNUSED_PARAMETER(node_name); for (auto i = 0; i < op_kernel_context->OutputCount(); i++) { const OrtValue* p_output = op_kernel_context->GetOutputMLValue(i); - if (p_output->IsTensor()) { + if (p_output != nullptr && p_output->IsTensor()) { const auto& tensor = p_output->Get(); size_t tensor_size = tensor.SizeInBytes(); #if defined(TRACE_EXECUTION) @@ -89,7 +89,7 @@ static void CalculateTotalInputSizes(const OpKernelContextInternal* op_kernel_co const int input_count = op_kernel_context->InputCount(); for (auto i = 0; i < input_count; i++) { const OrtValue* p_input = op_kernel_context->GetInputMLValue(i); - if (p_input->IsTensor()) { + if (p_input != nullptr && p_input->IsTensor()) { const OpKernelInfo& op_kernel_info = p_op_kernel->Info(); const Tensor* p_tensor = nullptr; bool is_param = op_kernel_info.TryGetConstantInput(i, &p_tensor); @@ -270,7 +270,7 @@ Status SequentialExecutor::Execute(const SessionState& session_state, const std: const std::string node_name_for_profiling = [&]() -> std::string { if (!is_profiler_enabled) return {}; - // Derive something meaningful for profile traces and logs if node name field is blank in execution graph + // Derive something meaningful for profile traces and logs if node name field is blank in execution graph return node.Name().empty() ? MakeString(node.OpType(), "_", node_index) : node.Name(); }();