Skip to content

Commit 7aa3339

Browse files
committed
Address review issue
1 parent 2a66cb9 commit 7aa3339

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

onnxruntime/core/framework/execution_frame.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,14 @@ Status IExecutionFrame::GetOrCreateNodeOutputMLValue(const int output_index, int
177177
bool shape_matched = true;
178178

179179
if (p_ort_value->IsTensor()) {
180-
if (shape) {
181-
const Tensor& tensor = p_ort_value->Get<Tensor>();
182-
shape_matched = (tensor.Shape() == *shape);
183-
}
180+
ORT_RETURN_IF_NOT(shape != nullptr, "shape must not be null for tensor output that is already allocated");
181+
const Tensor& tensor = p_ort_value->Get<Tensor>();
182+
shape_matched = (tensor.Shape() == *shape);
184183
} else if (p_ort_value->IsSparseTensor()) {
185184
#if !defined(DISABLE_SPARSE_TENSORS)
186-
if (shape) {
187-
const SparseTensor& sp_tensor = p_ort_value->Get<SparseTensor>();
188-
shape_matched = (sp_tensor.DenseShape() == *shape);
189-
}
185+
ORT_RETURN_IF_NOT(shape != nullptr, "shape must not be null for sparse tensor output that is already allocated");
186+
const SparseTensor& sp_tensor = p_ort_value->Get<SparseTensor>();
187+
shape_matched = (sp_tensor.DenseShape() == *shape);
190188
#endif
191189
}
192190

onnxruntime/core/framework/op_kernel.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ OrtValue* OpKernelContext::GetOrCreateOutputMLValue(int index) {
126126
auto output_arg_index = GetOutputArgIndex(index);
127127
OrtValue* value = nullptr;
128128
auto status = execution_frame_->GetOrCreateNodeOutputMLValue(index, output_arg_index, nullptr, value, kernel_->Node());
129-
ORT_ENFORCE(status.IsOK(), status.ErrorMessage());
129+
ORT_THROW_IF_ERROR(status);
130130
return value;
131131
}
132132

0 commit comments

Comments
 (0)