Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions kernels/test/op__clone_dim_order_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,8 @@ TEST_F(OpDimOrderCloneTest, AllDtypesSupported) {
}

// Cloning with mismatched input and output tensor shapes should fail.
#ifndef USE_ATEN_LIB
TEST_F(OpDimOrderCloneTest, MismatchedSizesDie) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "Skipping: ATen kernel supports mismatched sizes.";
}
TensorFactory<ScalarType::Int> tf;
Tensor input = tf.make(/*sizes=*/{3, 1, 1, 2}, /*data=*/{1, 2, 3, 4, 5, 6});
Tensor out = tf.zeros({3, 2, 1, 1});
Expand All @@ -175,13 +173,11 @@ TEST_F(OpDimOrderCloneTest, MismatchedSizesDie) {
dim_order,
out));
}
#endif

// Cloning with an unsupported memory format should fail.
#ifndef USE_ATEN_LIB
TEST_F(OpDimOrderCloneTest, MismatchedMemoryFormatDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP()
<< "Skipping: ATen kernel supports non-contiguous memory formats.";
}
TensorFactory<ScalarType::Float> tf_in;
TensorFactory<ScalarType::Float> tf_out;
Tensor input =
Expand All @@ -206,14 +202,12 @@ TEST_F(OpDimOrderCloneTest, MismatchedMemoryFormatDies) {
dim_order,
out));
}
#endif

// Cloning with non‑blocking=true should fail because portable kernels only
// support blocking.
#ifndef USE_ATEN_LIB
TEST_F(OpDimOrderCloneTest, MismatchedBlockingDie) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP()
<< "Skipping: ATen kernel supports non-blocking data transfer.";
}
TensorFactory<ScalarType::Int> tf;
Tensor input = tf.make(/*sizes=*/{3, 1, 1, 2}, /*data=*/{1, 2, 3, 4, 5, 6});
Tensor out = tf.zeros(/*sizes=*/{3, 1, 1, 2});
Expand All @@ -232,6 +226,7 @@ TEST_F(OpDimOrderCloneTest, MismatchedBlockingDie) {
dim_order,
out));
}
#endif

TEST_F(OpDimOrderCloneTest, DynamicShapeUpperBoundSameAsExpected) {
test_dynamic_shape(
Expand Down
15 changes: 6 additions & 9 deletions kernels/test/op__to_dim_order_copy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,8 @@ TEST_F(OpToDimOrderCopyTest, HardcodeFloatConvertInt) {
ET_FORALL_FLOATHBF16_TYPES(TEST_ENTRY);
}

#ifndef USE_ATEN_LIB
TEST_F(OpToDimOrderCopyTest, MismatchedSizesDie) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel can handle mismatched sizes";
}
TensorFactory<ScalarType::Int> tf;
Tensor input = tf.make(/*sizes=*/{3, 1, 1, 2}, /*data=*/{1, 2, 3, 4, 5, 6});
Tensor out = tf.zeros({3, 2, 1, 1});
Expand All @@ -479,14 +477,13 @@ TEST_F(OpToDimOrderCopyTest, MismatchedSizesDie) {
dim_order,
out));
}
#endif

// Only contiguous memory is supported, the memory type MemoryFormat::Contiguous
// should not be allowed. The function is expected death if using the illegal
// memory format.
#ifndef USE_ATEN_LIB
TEST_F(OpToDimOrderCopyTest, MismatchedMemoryFormatDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel can handle non contiguous memory formats";
}
TensorFactory<ScalarType::Float> tf_in;
TensorFactory<ScalarType::Float> tf_out;
Tensor input =
Expand All @@ -511,12 +508,11 @@ TEST_F(OpToDimOrderCopyTest, MismatchedMemoryFormatDies) {
dim_order,
out));
}
#endif

// Only blocking data transfer supported
#ifndef USE_ATEN_LIB
TEST_F(OpToDimOrderCopyTest, MismatchedBlockingDie) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel can handle non blocking data transfer";
}
TensorFactory<ScalarType::Int> tf;
Tensor input = tf.make(/*sizes=*/{3, 1, 1, 2}, /*data=*/{1, 2, 3, 4, 5, 6});
Tensor out = tf.zeros(/*sizes=*/{3, 1, 1, 2});
Expand All @@ -535,6 +531,7 @@ TEST_F(OpToDimOrderCopyTest, MismatchedBlockingDie) {
dim_order,
out));
}
#endif

TEST_F(OpToDimOrderCopyTest, DynamicShapeUpperBoundSameAsExpected) {
test_dynamic_shape(
Expand Down
15 changes: 6 additions & 9 deletions kernels/test/op_amax_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,30 +259,26 @@ void OpAmaxOutTest::test_amax_out_dtype<ScalarType::Bool>() {
// clang-format on
}

#ifndef USE_ATEN_LIB
TEST_F(OpAmaxOutTest, InvalidDimensionListDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel test fails";
}
#define TEST_ENTRY(ctype, dtype) \
test_amax_out_invalid_dimensions<ScalarType::dtype>();
ET_FORALL_REAL_TYPES_AND(Bool, TEST_ENTRY);
#undef TEST_ENTRY
}
#endif

#ifndef USE_ATEN_LIB
TEST_F(OpAmaxOutTest, InvalidShapeDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel test fails";
}
#define TEST_ENTRY(ctype, dtype) \
test_amax_out_invalid_shape<ScalarType::dtype>();
ET_FORALL_REAL_TYPES_AND(Bool, TEST_ENTRY);
#undef TEST_ENTRY
}
#endif

#ifndef USE_ATEN_LIB
TEST_F(OpAmaxOutTest, MismatchedDTypesDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel test fails";
}
TensorFactory<ScalarType::Float> tf_float;
TensorFactory<ScalarType::Int> tf_int;

Expand All @@ -308,6 +304,7 @@ TEST_F(OpAmaxOutTest, MismatchedDTypesDies) {
ET_EXPECT_KERNEL_FAILURE(
context_, op_amax_out(in, dim_list, /*keepdim=*/true, out));
}
#endif

TEST_F(OpAmaxOutTest, AllRealInputOutputPasses) {
#define TEST_ENTRY(ctype, dtype) test_amax_out_dtype<ScalarType::dtype>();
Expand Down
15 changes: 6 additions & 9 deletions kernels/test/op_amin_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,30 +258,26 @@ void OpAminOutTest::test_amin_out_dtype<ScalarType::Bool>() {
// clang-format on
}

#ifndef USE_ATEN_LIB
TEST_F(OpAminOutTest, InvalidDimensionListDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel test fails";
}
#define TEST_ENTRY(ctype, dtype) \
test_amin_out_invalid_dimensions<ScalarType::dtype>();
ET_FORALL_REAL_TYPES_AND(Bool, TEST_ENTRY);
#undef TEST_ENTRY
}
#endif

#ifndef USE_ATEN_LIB
TEST_F(OpAminOutTest, InvalidShapeDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel test fails";
}
#define TEST_ENTRY(ctype, dtype) \
test_amin_out_invalid_shape<ScalarType::dtype>();
ET_FORALL_REAL_TYPES_AND(Bool, TEST_ENTRY);
#undef TEST_ENTRY
}
#endif

#ifndef USE_ATEN_LIB
TEST_F(OpAminOutTest, MismatchedDTypesDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel test fails";
}
TensorFactory<ScalarType::Float> tf_float;
TensorFactory<ScalarType::Int> tf_int;

Expand All @@ -307,6 +303,7 @@ TEST_F(OpAminOutTest, MismatchedDTypesDies) {
ET_EXPECT_KERNEL_FAILURE(
context_, op_amin_out(in, dim_list, /*keepdim=*/true, out));
}
#endif

TEST_F(OpAminOutTest, AllRealInputOutputPasses) {
#define TEST_ENTRY(ctype, dtype) test_amin_out_dtype<ScalarType::dtype>();
Expand Down
5 changes: 2 additions & 3 deletions kernels/test/op_any_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ class OpAnyOutTest : public OperatorTest {
}
};

#ifndef USE_ATEN_LIB
TEST_F(OpAnyOutTest, MismatchedDimensionsDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel can handle mismatched dimensions";
}
TensorFactory<ScalarType::Float> tff;
const std::vector<int32_t> size{2, 2};

Expand All @@ -110,6 +108,7 @@ TEST_F(OpAnyOutTest, MismatchedDimensionsDies) {

ET_EXPECT_KERNEL_FAILURE(context_, op_any_all_out(in, out));
}
#endif

TEST_F(OpAnyOutTest, InvalidDtypeDies) {
#define TEST_ENTRY(ctype, dtype) \
Expand Down
20 changes: 8 additions & 12 deletions kernels/test/op_arange_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,8 @@ TEST_F(OpArangeOutTest, FloatNumberNotEqualIntSupport) {
EXPECT_TENSOR_EQ(out, expected);
}

#ifndef USE_ATEN_LIB
TEST_F(OpArangeOutTest, OutDimUnsupportedDie) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel can handle mismatched out dim";
}
TensorFactory<ScalarType::Float> tf;

Scalar end = Scalar(5);
Expand All @@ -126,6 +124,7 @@ TEST_F(OpArangeOutTest, OutDimUnsupportedDie) {
// out.dim() should be 1, not 2
ET_EXPECT_KERNEL_FAILURE(context_, op_arange_out(end, out));
}
#endif

TEST_F(OpArangeOutTest, DynamicShapeUpperBoundSameAsExpected) {
TensorFactory<ScalarType::Float> tf;
Expand All @@ -149,10 +148,8 @@ TEST_F(OpArangeOutTest, DynamicShapeUpperBoundLargerThanExpected) {
EXPECT_TENSOR_CLOSE(out, expected_result);
}

#ifdef USE_ATEN_LIB
TEST_F(OpArangeOutTest, DynamicShapeUnbound) {
if (!torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "Dynamic Unbound not supported";
}
TensorFactory<ScalarType::Float> tf;

Tensor expected_result = tf.make({5}, {0, 1, 2, 3, 4});
Expand All @@ -162,6 +159,7 @@ TEST_F(OpArangeOutTest, DynamicShapeUnbound) {
Tensor ret = op_arange_out(Scalar(5), out);
EXPECT_TENSOR_CLOSE(out, expected_result);
}
#endif

/// A generic smoke test that works for any dtype that supports zeros().
TEST_F(OpArangeStartOutTest, AllRealHBF16DtypesSupported) {
Expand Down Expand Up @@ -195,10 +193,8 @@ TEST_F(OpArangeStartOutTest, FloatNumberNotEqualIntSupport) {
EXPECT_TENSOR_EQ(out, expected);
}

#ifndef USE_ATEN_LIB
TEST_F(OpArangeStartOutTest, OutDimUnsupportedDie) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel can handle mismatched out dim";
}
TensorFactory<ScalarType::Float> tf;

Scalar start = Scalar(0);
Expand All @@ -211,6 +207,7 @@ TEST_F(OpArangeStartOutTest, OutDimUnsupportedDie) {
ET_EXPECT_KERNEL_FAILURE(
context_, op_arange_start_out(start, end, step, out));
}
#endif

TEST_F(OpArangeStartOutTest, DynamicShapeUpperBoundSameAsExpected) {
TensorFactory<ScalarType::Float> tf;
Expand All @@ -234,10 +231,8 @@ TEST_F(OpArangeStartOutTest, DynamicShapeUpperBoundLargerThanExpected) {
EXPECT_TENSOR_CLOSE(out, expected_result);
}

#ifdef USE_ATEN_LIB
TEST_F(OpArangeStartOutTest, DynamicShapeUnbound) {
if (!torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "Dynamic Unbound not supported";
}
TensorFactory<ScalarType::Float> tf;

Tensor expected_result = tf.make({5}, {0, 1, 2, 3, 4});
Expand All @@ -247,6 +242,7 @@ TEST_F(OpArangeStartOutTest, DynamicShapeUnbound) {
Tensor ret = op_arange_start_out(Scalar(0), Scalar(5), Scalar(1), out);
EXPECT_TENSOR_CLOSE(out, expected_result);
}
#endif

TEST_F(OpArangeStartOutTest, StartOut) {
TensorFactory<ScalarType::Float> tf;
Expand Down
5 changes: 2 additions & 3 deletions kernels/test/op_as_strided_copy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,14 @@ TEST_F(OpAsStridedCopyOutTest, AllScalarInputOutputSupport) {
#undef TEST_ENTRY
}

#ifndef USE_ATEN_LIB
TEST_F(OpAsStridedCopyOutTest, InvalidParametersDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel can handle invalid parameter";
}
#define TEST_ENTRY(ctype, dtype) \
test_as_strided_copy_out_invalid_parameters<ScalarType::dtype>();
ET_FORALL_REAL_TYPES_AND(Bool, TEST_ENTRY);
#undef TEST_ENTRY
}
#endif

TEST_F(OpAsStridedCopyOutTest, MismatchedInputDtypesDies) {
TensorFactory<ScalarType::Byte> tf_byte;
Expand Down
5 changes: 2 additions & 3 deletions kernels/test/op_bitwise_not_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,16 @@ TEST_F(OpBitwiseNotOutTest, BoolInputOutputSupport) {
}

// Mismatched shape tests.
#ifndef USE_ATEN_LIB
TEST_F(OpBitwiseNotOutTest, MismatchedShapesDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel can handle mismatched shapes";
}
TensorFactory<ScalarType::Int> tf;

Tensor a = tf.ones(/*sizes=*/{4});
Tensor out = tf.ones(/*sizes=*/{2, 2});

ET_EXPECT_KERNEL_FAILURE(context_, op_bitwise_not_out(a, out));
}
#endif

TEST_F(OpBitwiseNotOutTest, AllFloatInputDTypeDies) {
#define TEST_ENTRY(ctype, dtype) \
Expand Down
10 changes: 4 additions & 6 deletions kernels/test/op_bmm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,8 @@ TEST_F(OpBmmOutTest, MismatchedDimensionsDies) {
EXPECT_TENSOR_EQ(op_bmm_out(x, right_y, out), tf.full({2, 10, 4}, 3));
}

#ifndef USE_ATEN_LIB
TEST_F(OpBmmOutTest, MismatchedDimensionSizeDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel can handle mismatched dimension size";
}
TensorFactory<ScalarType::Int> tf;

Tensor x = tf.ones({2, 10, 3});
Expand All @@ -259,11 +257,10 @@ TEST_F(OpBmmOutTest, MismatchedDimensionSizeDies) {
ET_EXPECT_KERNEL_FAILURE(context_, op_bmm_out(x, right_y, wrong_out));
ET_EXPECT_KERNEL_FAILURE(context_, op_bmm_out(x, wrong_y, right_out));
}
#endif

#ifndef USE_ATEN_LIB
TEST_F(OpBmmOutTest, WrongOutShapeDies) {
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
GTEST_SKIP() << "ATen kernel can handle wrong out shape";
}
TensorFactory<ScalarType::Int> tf;

Tensor x = tf.ones({2, 10, 3});
Expand All @@ -278,6 +275,7 @@ TEST_F(OpBmmOutTest, WrongOutShapeDies) {

EXPECT_TENSOR_EQ(op_bmm_out(x, y, right_out), tf.full({2, 10, 4}, 3));
}
#endif

TEST_F(OpBmmOutTest, DynamicShapeUpperBoundSameAsExpected) {
TensorFactory<ScalarType::Float> tf;
Expand Down
Loading
Loading