Skip to content

Commit 36cf9c4

Browse files
committed
Let SafeInt<> exception propagate
1 parent 174b9ad commit 36cf9c4

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

onnxruntime/core/providers/cpu/nn/conv_transpose_attributes.h

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -329,28 +329,16 @@ struct ConvTransposeAttributes : public ConvAttributes {
329329
if (pad_type == AutoPadType::SAME_UPPER || pad_type == AutoPadType::SAME_LOWER) {
330330
// The ONNX spec says if `auto_pad` attribute is set, pad until the `out_size`
331331
// is `in_size * stride`
332-
ORT_TRY {
333-
int64_t auto_out_size = SafeInt<int64_t>(in_size) * stride;
334-
auto total_pad = ComputeTotalPad(in_size, stride, adj,
335-
kernel, dilation, auto_out_size);
336-
DistributePadding(pad_type, total_pad, *pad_head, *pad_tail);
337-
}
338-
ORT_CATCH(const OnnxRuntimeException&) {
339-
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT,
340-
"Integer overflow in ConvTranspose output size computation.");
341-
}
332+
int64_t auto_out_size = SafeInt<int64_t>(in_size) * stride;
333+
auto total_pad = ComputeTotalPad(in_size, stride, adj,
334+
kernel, dilation, auto_out_size);
335+
DistributePadding(pad_type, total_pad, *pad_head, *pad_tail);
342336
}
343337

344338
// *out_size = (in_size - 1) * stride + adj + (kernel - 1) * dilation + 1 - *pad_head - *pad_tail
345-
ORT_TRY {
346-
*out_size = SafeInt<int64_t>(in_size - 1) * stride + adj +
347-
SafeInt<int64_t>(kernel - 1) * dilation + 1 -
348-
*pad_head - *pad_tail;
349-
}
350-
ORT_CATCH(const OnnxRuntimeException&) {
351-
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT,
352-
"Integer overflow in ConvTranspose output size computation.");
353-
}
339+
*out_size = SafeInt<int64_t>(in_size - 1) * stride + adj +
340+
SafeInt<int64_t>(kernel - 1) * dilation + 1 -
341+
*pad_head - *pad_tail;
354342
return Status::OK();
355343
}
356344
};

0 commit comments

Comments
 (0)