|
7 | 7 | */
|
8 | 8 |
|
9 | 9 | #include <executorch/kernels/test/FunctionHeaderWrapper.h> // Declares the operator
|
| 10 | +#include <executorch/kernels/test/ScalarOverflowTestMacros.h> |
10 | 11 | #include <executorch/kernels/test/TestUtil.h>
|
11 | 12 | #include <executorch/kernels/test/supported_features.h>
|
12 | 13 | #include <executorch/runtime/core/exec_aten/exec_aten.h>
|
@@ -347,6 +348,21 @@ class OpConstantPadNDOutTest : public OperatorTest {
|
347 | 348 | op_constant_pad_nd_out(self, padding_ref, 7, out);
|
348 | 349 | EXPECT_TENSOR_CLOSE(out, expected);
|
349 | 350 | }
|
| 351 | + |
| 352 | + template <ScalarType DTYPE> |
| 353 | + void expect_bad_scalar_value_dies(const Scalar& bad_value) { |
| 354 | + TensorFactory<DTYPE> tf; |
| 355 | + const std::vector<int32_t> sizes = {2, 2}; |
| 356 | + const std::vector<int32_t> sizes_out = {2, 4}; |
| 357 | + const std::vector<int64_t> padding = {1, 1}; |
| 358 | + |
| 359 | + IntArrayRef padding_ref = IntArrayRef(padding.data(), padding.size()); |
| 360 | + Tensor self = tf.ones(sizes); |
| 361 | + Tensor out = tf.zeros(sizes_out); |
| 362 | + |
| 363 | + ET_EXPECT_KERNEL_FAILURE( |
| 364 | + context_, op_constant_pad_nd_out(self, padding_ref, bad_value, out)); |
| 365 | + } |
350 | 366 | };
|
351 | 367 |
|
352 | 368 | TEST_F(OpConstantPadNDOutTest, TestPadDim2) {
|
@@ -465,3 +481,5 @@ TEST_F(OpConstantPadNDOutTest, IncorrectOutputShapeFail) {
|
465 | 481 | ET_EXPECT_KERNEL_FAILURE(
|
466 | 482 | context_, op_constant_pad_nd_out(self, padding_ref, 0, out));
|
467 | 483 | }
|
| 484 | + |
| 485 | +GENERATE_SCALAR_OVERFLOW_TESTS(OpConstantPadNDOutTest) |
0 commit comments