Skip to content

Commit 6bc1762

Browse files
authored
Migrate broken tests to ET_SKIP_IF macro (pytorch#19659)
Differential Revision: D105645070 Pull Request resolved: pytorch#19659
1 parent 1ec6812 commit 6bc1762

85 files changed

Lines changed: 733 additions & 670 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

kernels/test/UnaryUfuncRealHBBF16ToFloatHBF16Test.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include <executorch/kernels/test/UnaryUfuncRealHBBF16ToFloatHBF16Test.h>
10+
#include <executorch/kernels/test/supported_features_skip.h>
1011

1112
namespace torch::executor::testing {
1213
void UnaryUfuncRealHBBF16ToFloatHBF16Test::test_bool_input() {
@@ -25,9 +26,9 @@ void UnaryUfuncRealHBBF16ToFloatHBF16Test::test_bool_input() {
2526
}
2627

2728
void UnaryUfuncRealHBBF16ToFloatHBF16Test::test_mismatched_input_shapes_dies() {
28-
if (get_supported_features()->is_aten) {
29-
GTEST_SKIP() << "ATen kernel can handle mismatched input shapes";
30-
}
29+
ET_SKIP_IF(
30+
get_supported_features()->is_aten,
31+
"ATen kernel can handle mismatched input shapes");
3132
TensorFactory<executorch::aten::ScalarType::Float> tf;
3233

3334
executorch::aten::Tensor a = tf.ones(/*sizes=*/{4});
@@ -122,9 +123,9 @@ void UnaryUfuncRealHBBF16ToFloatHBF16Test::
122123

123124
void UnaryUfuncRealHBBF16ToFloatHBF16Test::
124125
test_all_real_input_float_output_unbound_dynamism_support() {
125-
if (!get_supported_features()->is_aten) {
126-
GTEST_SKIP() << "Dynamic shape unbound not supported";
127-
}
126+
ET_SKIP_IF(
127+
!get_supported_features()->is_aten,
128+
"Dynamic shape unbound not supported");
128129
#define TEST_ENTRY(ctype, dtype) \
129130
test_floating_point_op_out< \
130131
executorch::aten::ScalarType::dtype, \
@@ -136,9 +137,9 @@ void UnaryUfuncRealHBBF16ToFloatHBF16Test::
136137

137138
void UnaryUfuncRealHBBF16ToFloatHBF16Test::
138139
test_all_real_input_double_output_unbound_dynamism_support() {
139-
if (!get_supported_features()->is_aten) {
140-
GTEST_SKIP() << "Dynamic shape unbound not supported";
141-
}
140+
ET_SKIP_IF(
141+
!get_supported_features()->is_aten,
142+
"Dynamic shape unbound not supported");
142143
#define TEST_ENTRY(ctype, dtype) \
143144
test_floating_point_op_out< \
144145
executorch::aten::ScalarType::dtype, \

kernels/test/UnaryUfuncRealHBBF16ToFloatHBF16Test.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <executorch/kernels/test/TestUtil.h>
1212
#include <executorch/kernels/test/supported_features.h>
13+
#include <executorch/kernels/test/supported_features_skip.h>
1314
#include <executorch/runtime/core/exec_aten/exec_aten.h>
1415
#include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
1516
#include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>

kernels/test/op__clone_dim_order_test.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <executorch/kernels/test/FunctionHeaderWrapper.h> // Declares the operator.
1212
#include <executorch/kernels/test/TestUtil.h>
1313
#include <executorch/kernels/test/supported_features.h>
14+
#include <executorch/kernels/test/supported_features_skip.h>
1415
#include <executorch/runtime/core/exec_aten/exec_aten.h>
1516
#include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
1617
#include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>
@@ -155,9 +156,9 @@ TEST_F(OpDimOrderCloneTest, AllDtypesSupported) {
155156

156157
// Cloning with mismatched input and output tensor shapes should fail.
157158
TEST_F(OpDimOrderCloneTest, MismatchedSizesDie) {
158-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
159-
GTEST_SKIP() << "Skipping: ATen kernel supports mismatched sizes.";
160-
}
159+
ET_SKIP_IF(
160+
torch::executor::testing::SupportedFeatures::get()->is_aten,
161+
"Skipping: ATen kernel supports mismatched sizes.");
161162
TensorFactory<ScalarType::Int> tf;
162163
Tensor input = tf.make(/*sizes=*/{3, 1, 1, 2}, /*data=*/{1, 2, 3, 4, 5, 6});
163164
Tensor out = tf.zeros({3, 2, 1, 1});
@@ -178,10 +179,9 @@ TEST_F(OpDimOrderCloneTest, MismatchedSizesDie) {
178179

179180
// Cloning with an unsupported memory format should fail.
180181
TEST_F(OpDimOrderCloneTest, MismatchedMemoryFormatDies) {
181-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
182-
GTEST_SKIP()
183-
<< "Skipping: ATen kernel supports non-contiguous memory formats.";
184-
}
182+
ET_SKIP_IF(
183+
torch::executor::testing::SupportedFeatures::get()->is_aten,
184+
"Skipping: ATen kernel supports non-contiguous memory formats.");
185185
TensorFactory<ScalarType::Float> tf_in;
186186
TensorFactory<ScalarType::Float> tf_out;
187187
Tensor input =
@@ -210,10 +210,9 @@ TEST_F(OpDimOrderCloneTest, MismatchedMemoryFormatDies) {
210210
// Cloning with non‑blocking=true should fail because portable kernels only
211211
// support blocking.
212212
TEST_F(OpDimOrderCloneTest, MismatchedBlockingDie) {
213-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
214-
GTEST_SKIP()
215-
<< "Skipping: ATen kernel supports non-blocking data transfer.";
216-
}
213+
ET_SKIP_IF(
214+
torch::executor::testing::SupportedFeatures::get()->is_aten,
215+
"Skipping: ATen kernel supports non-blocking data transfer.");
217216
TensorFactory<ScalarType::Int> tf;
218217
Tensor input = tf.make(/*sizes=*/{3, 1, 1, 2}, /*data=*/{1, 2, 3, 4, 5, 6});
219218
Tensor out = tf.zeros(/*sizes=*/{3, 1, 1, 2});
@@ -244,9 +243,9 @@ TEST_F(OpDimOrderCloneTest, DynamicShapeUpperBoundLargerThanExpected) {
244243
}
245244

246245
TEST_F(OpDimOrderCloneTest, DynamicShapeUnbound) {
247-
if (!torch::executor::testing::SupportedFeatures::get()->output_resize) {
248-
GTEST_SKIP() << "Skipping: Dynamic shape unbound not supported.";
249-
}
246+
ET_SKIP_IF(
247+
!torch::executor::testing::SupportedFeatures::get()->output_resize,
248+
"Skipping: Dynamic shape unbound not supported.");
250249
test_dynamic_shape(
251250
{1, 1}, torch::executor::TensorShapeDynamism::DYNAMIC_UNBOUND);
252251
}

kernels/test/op__empty_dim_order_test.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <executorch/kernels/test/FunctionHeaderWrapper.h> // Declares the operator
1010
#include <executorch/kernels/test/TestUtil.h>
1111
#include <executorch/kernels/test/supported_features.h>
12+
#include <executorch/kernels/test/supported_features_skip.h>
1213
#include <executorch/runtime/core/exec_aten/exec_aten.h>
1314
#include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
1415
#include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>
@@ -147,9 +148,9 @@ TEST_F(OpEmptyDimOrderOutTest, DynamicShapeUpperBoundLargerThanExpected) {
147148
}
148149

149150
TEST_F(OpEmptyDimOrderOutTest, DynamicShapeUnbound) {
150-
if (!torch::executor::testing::SupportedFeatures::get()->output_resize) {
151-
GTEST_SKIP() << "Dynamic shape unbound not supported";
152-
}
151+
ET_SKIP_IF(
152+
!torch::executor::testing::SupportedFeatures::get()->output_resize,
153+
"Dynamic shape unbound not supported");
153154
TensorFactory<ScalarType::Float> tf;
154155

155156
int64_t sizes[2] = {3, 2};

kernels/test/op__to_dim_order_copy_test.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <executorch/kernels/test/FunctionHeaderWrapper.h> // Declares the operator
1515
#include <executorch/kernels/test/TestUtil.h>
1616
#include <executorch/kernels/test/supported_features.h>
17+
#include <executorch/kernels/test/supported_features_skip.h>
1718
#include <executorch/runtime/core/exec_aten/exec_aten.h>
1819
#include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
1920
#include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>
@@ -459,9 +460,9 @@ TEST_F(OpToDimOrderCopyTest, HardcodeFloatConvertInt) {
459460
}
460461

461462
TEST_F(OpToDimOrderCopyTest, MismatchedSizesDie) {
462-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
463-
GTEST_SKIP() << "ATen kernel can handle mismatched sizes";
464-
}
463+
ET_SKIP_IF(
464+
torch::executor::testing::SupportedFeatures::get()->is_aten,
465+
"ATen kernel can handle mismatched sizes");
465466
TensorFactory<ScalarType::Int> tf;
466467
Tensor input = tf.make(/*sizes=*/{3, 1, 1, 2}, /*data=*/{1, 2, 3, 4, 5, 6});
467468
Tensor out = tf.zeros({3, 2, 1, 1});
@@ -484,9 +485,9 @@ TEST_F(OpToDimOrderCopyTest, MismatchedSizesDie) {
484485
// should not be allowed. The function is expected death if using the illegal
485486
// memory format.
486487
TEST_F(OpToDimOrderCopyTest, MismatchedMemoryFormatDies) {
487-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
488-
GTEST_SKIP() << "ATen kernel can handle non contiguous memory formats";
489-
}
488+
ET_SKIP_IF(
489+
torch::executor::testing::SupportedFeatures::get()->is_aten,
490+
"ATen kernel can handle non contiguous memory formats");
490491
TensorFactory<ScalarType::Float> tf_in;
491492
TensorFactory<ScalarType::Float> tf_out;
492493
Tensor input =
@@ -514,9 +515,9 @@ TEST_F(OpToDimOrderCopyTest, MismatchedMemoryFormatDies) {
514515

515516
// Only blocking data transfer supported
516517
TEST_F(OpToDimOrderCopyTest, MismatchedBlockingDie) {
517-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
518-
GTEST_SKIP() << "ATen kernel can handle non blocking data transfer";
519-
}
518+
ET_SKIP_IF(
519+
torch::executor::testing::SupportedFeatures::get()->is_aten,
520+
"ATen kernel can handle non blocking data transfer");
520521
TensorFactory<ScalarType::Int> tf;
521522
Tensor input = tf.make(/*sizes=*/{3, 1, 1, 2}, /*data=*/{1, 2, 3, 4, 5, 6});
522523
Tensor out = tf.zeros(/*sizes=*/{3, 1, 1, 2});
@@ -547,9 +548,9 @@ TEST_F(OpToDimOrderCopyTest, DynamicShapeUpperBoundLargerThanExpected) {
547548
}
548549

549550
TEST_F(OpToDimOrderCopyTest, DynamicShapeUnbound) {
550-
if (!torch::executor::testing::SupportedFeatures::get()->output_resize) {
551-
GTEST_SKIP() << "Dynamic shape unbound not supported";
552-
}
551+
ET_SKIP_IF(
552+
!torch::executor::testing::SupportedFeatures::get()->output_resize,
553+
"Dynamic shape unbound not supported");
553554
test_dynamic_shape(
554555
{1, 1}, torch::executor::TensorShapeDynamism::DYNAMIC_UNBOUND);
555556
}

kernels/test/op_add_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <executorch/kernels/test/ScalarOverflowTestMacros.h>
1111
#include <executorch/kernels/test/TestUtil.h>
1212
#include <executorch/kernels/test/supported_features.h>
13+
#include <executorch/kernels/test/supported_features_skip.h>
1314
#include <executorch/runtime/core/exec_aten/exec_aten.h>
1415
#include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
1516
#include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>
@@ -686,10 +687,9 @@ TEST_F(OpAddOutKernelTest, MismatchedNonBroadcastableInputShapesDies) {
686687
}
687688

688689
TEST_F(OpAddOutKernelTest, MismatchedOutputShapesDies) {
689-
if (SupportedFeatures::get()->output_resize) {
690-
GTEST_SKIP()
691-
<< "The current kernel supports implicitly resizing output tensor";
692-
}
690+
ET_SKIP_IF(
691+
SupportedFeatures::get()->output_resize,
692+
"The current kernel supports implicitly resizing output tensor");
693693

694694
TensorFactory<ScalarType::Int> tf;
695695

kernels/test/op_addmm_test.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <executorch/kernels/test/FunctionHeaderWrapper.h> // Declares the operator
1010
#include <executorch/kernels/test/TestUtil.h>
1111
#include <executorch/kernels/test/supported_features.h>
12+
#include <executorch/kernels/test/supported_features_skip.h>
1213
#include <executorch/runtime/core/exec_aten/exec_aten.h>
1314
#include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
1415
#include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>
@@ -42,11 +43,9 @@ class OpAddmmOutTest : public OperatorTest {
4243
TensorFactory<DTYPE> tf;
4344

4445
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
45-
if (DTYPE == ScalarType::Half) {
46-
GTEST_SKIP()
47-
<< "skip Half because torch::executor::aten::mm_out does not support Half";
48-
return;
49-
}
46+
ET_SKIP_IF(
47+
DTYPE == ScalarType::Half,
48+
"skip Half because torch::executor::aten::mm_out does not support Half");
5049
}
5150

5251
// matmul gives 4 * 2 * 3 = 24, α * 24 = 48, 48 + β * self = 51
@@ -205,9 +204,9 @@ TEST_F(OpAddmmOutTest, MismatchedDimensionSizeDies) {
205204
Tensor right_out = tf.ones({2, 2});
206205
Tensor wrong_out = tf.ones({2, 2, 3});
207206

208-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
209-
GTEST_SKIP() << "ATen kernel can handle mismatched dimensions";
210-
}
207+
ET_SKIP_IF(
208+
torch::executor::testing::SupportedFeatures::get()->is_aten,
209+
"ATen kernel can handle mismatched dimensions");
211210

212211
ET_EXPECT_KERNEL_FAILURE(
213212
context_,
@@ -228,9 +227,9 @@ TEST_F(OpAddmmOutTest, WrongOutShapeDies) {
228227
Tensor right_out = tf.ones({10, 4});
229228
Tensor wrong_out = tf.ones({7, 5});
230229

231-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
232-
GTEST_SKIP() << "ATen kernel can handle wrong out shape";
233-
}
230+
ET_SKIP_IF(
231+
torch::executor::testing::SupportedFeatures::get()->is_aten,
232+
"ATen kernel can handle wrong out shape");
234233

235234
ET_EXPECT_KERNEL_FAILURE(
236235
context_, op_addmm_out(self, x, y, Scalar(1), Scalar(1), wrong_out));

kernels/test/op_amax_test.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <executorch/kernels/test/FunctionHeaderWrapper.h> // Declares the operator
1010
#include <executorch/kernels/test/TestUtil.h>
1111
#include <executorch/kernels/test/supported_features.h>
12+
#include <executorch/kernels/test/supported_features_skip.h>
1213
#include <executorch/runtime/core/exec_aten/exec_aten.h>
1314
#include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
1415
#include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>
@@ -260,29 +261,29 @@ void OpAmaxOutTest::test_amax_out_dtype<ScalarType::Bool>() {
260261
}
261262

262263
TEST_F(OpAmaxOutTest, InvalidDimensionListDies) {
263-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
264-
GTEST_SKIP() << "ATen kernel test fails";
265-
}
264+
ET_SKIP_IF(
265+
torch::executor::testing::SupportedFeatures::get()->is_aten,
266+
"ATen kernel test fails");
266267
#define TEST_ENTRY(ctype, dtype) \
267268
test_amax_out_invalid_dimensions<ScalarType::dtype>();
268269
ET_FORALL_REAL_TYPES_AND(Bool, TEST_ENTRY);
269270
#undef TEST_ENTRY
270271
}
271272

272273
TEST_F(OpAmaxOutTest, InvalidShapeDies) {
273-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
274-
GTEST_SKIP() << "ATen kernel test fails";
275-
}
274+
ET_SKIP_IF(
275+
torch::executor::testing::SupportedFeatures::get()->is_aten,
276+
"ATen kernel test fails");
276277
#define TEST_ENTRY(ctype, dtype) \
277278
test_amax_out_invalid_shape<ScalarType::dtype>();
278279
ET_FORALL_REAL_TYPES_AND(Bool, TEST_ENTRY);
279280
#undef TEST_ENTRY
280281
}
281282

282283
TEST_F(OpAmaxOutTest, MismatchedDTypesDies) {
283-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
284-
GTEST_SKIP() << "ATen kernel test fails";
285-
}
284+
ET_SKIP_IF(
285+
torch::executor::testing::SupportedFeatures::get()->is_aten,
286+
"ATen kernel test fails");
286287
TensorFactory<ScalarType::Float> tf_float;
287288
TensorFactory<ScalarType::Int> tf_int;
288289

kernels/test/op_amin_test.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <executorch/kernels/test/FunctionHeaderWrapper.h> // Declares the operator
1010
#include <executorch/kernels/test/TestUtil.h>
1111
#include <executorch/kernels/test/supported_features.h>
12+
#include <executorch/kernels/test/supported_features_skip.h>
1213
#include <executorch/runtime/core/exec_aten/exec_aten.h>
1314
#include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
1415
#include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>
@@ -259,29 +260,29 @@ void OpAminOutTest::test_amin_out_dtype<ScalarType::Bool>() {
259260
}
260261

261262
TEST_F(OpAminOutTest, InvalidDimensionListDies) {
262-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
263-
GTEST_SKIP() << "ATen kernel test fails";
264-
}
263+
ET_SKIP_IF(
264+
torch::executor::testing::SupportedFeatures::get()->is_aten,
265+
"ATen kernel test fails");
265266
#define TEST_ENTRY(ctype, dtype) \
266267
test_amin_out_invalid_dimensions<ScalarType::dtype>();
267268
ET_FORALL_REAL_TYPES_AND(Bool, TEST_ENTRY);
268269
#undef TEST_ENTRY
269270
}
270271

271272
TEST_F(OpAminOutTest, InvalidShapeDies) {
272-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
273-
GTEST_SKIP() << "ATen kernel test fails";
274-
}
273+
ET_SKIP_IF(
274+
torch::executor::testing::SupportedFeatures::get()->is_aten,
275+
"ATen kernel test fails");
275276
#define TEST_ENTRY(ctype, dtype) \
276277
test_amin_out_invalid_shape<ScalarType::dtype>();
277278
ET_FORALL_REAL_TYPES_AND(Bool, TEST_ENTRY);
278279
#undef TEST_ENTRY
279280
}
280281

281282
TEST_F(OpAminOutTest, MismatchedDTypesDies) {
282-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
283-
GTEST_SKIP() << "ATen kernel test fails";
284-
}
283+
ET_SKIP_IF(
284+
torch::executor::testing::SupportedFeatures::get()->is_aten,
285+
"ATen kernel test fails");
285286
TensorFactory<ScalarType::Float> tf_float;
286287
TensorFactory<ScalarType::Int> tf_int;
287288

kernels/test/op_any_test.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <executorch/kernels/test/FunctionHeaderWrapper.h> // Declares the operator
1010
#include <executorch/kernels/test/TestUtil.h>
1111
#include <executorch/kernels/test/supported_features.h>
12+
#include <executorch/kernels/test/supported_features_skip.h>
1213
#include <executorch/runtime/core/exec_aten/exec_aten.h>
1314
#include <executorch/runtime/core/exec_aten/testing_util/tensor_factory.h>
1415
#include <executorch/runtime/core/exec_aten/testing_util/tensor_util.h>
@@ -99,9 +100,9 @@ class OpAnyOutTest : public OperatorTest {
99100
};
100101

101102
TEST_F(OpAnyOutTest, MismatchedDimensionsDies) {
102-
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
103-
GTEST_SKIP() << "ATen kernel can handle mismatched dimensions";
104-
}
103+
ET_SKIP_IF(
104+
torch::executor::testing::SupportedFeatures::get()->is_aten,
105+
"ATen kernel can handle mismatched dimensions");
105106
TensorFactory<ScalarType::Float> tff;
106107
const std::vector<int32_t> size{2, 2};
107108

0 commit comments

Comments
 (0)