fix optional input/outputs (#4229)

This commit is contained in:
Tracy Sharpe 2020-06-14 15:10:22 -07:00 committed by GitHub
parent 5708c4feaf
commit bf3c32166d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<Tensor>();
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();
}();