Skip to content
Closed
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
3 changes: 2 additions & 1 deletion kernels/optimized/cpu/op_div.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ Tensor& opt_div_scalar_out(
auto error = resize_tensor(out, a.sizes());
ET_CHECK_MSG(error == Error::Ok, "Failed to resize output tensor.");

if (a_type == common_type && a_type == out_type) {
if (a_type == common_type && a_type == out_type &&
a_type != ScalarType::Half && a_type != ScalarType::BFloat16) {
ET_SWITCH_REAL_TYPES(a_type, ctx, "div.Scalar_out", CTYPE, [&]() {
ET_SWITCH_REAL_TYPES_AND(
Bool, b_type, ctx, "div.Scalar_out", CTYPE_B, [&]() {
Expand Down
3 changes: 2 additions & 1 deletion kernels/optimized/cpu/op_le.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ Tensor& opt_le_scalar_out(
ScalarType common_type = promoteTypes(a_type, b_type);
ScalarType out_type = out.scalar_type();

if (a_type == common_type && a_type == out_type) {
if (a_type == common_type && a_type == out_type &&
a_type != ScalarType::Half && a_type != ScalarType::BFloat16) {
ET_SWITCH_REAL_TYPES_AND(Bool, a_type, ctx, "le.Scalar_out", CTYPE, [&]() {
ET_SWITCH_REAL_TYPES_AND(
Bool, b_type, ctx, "le.Scalar_out", CTYPE_B, [&]() {
Expand Down
11 changes: 5 additions & 6 deletions kernels/test/op_div_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class OpDivOutTest : public OperatorTest {
#define ENUMERATE_TEST_ENTRY(ctype, dtype) \
test_div<DTYPE_A, DTYPE_B, ScalarType::dtype>();

ET_FORALL_FLOAT_TYPES(ENUMERATE_TEST_ENTRY)
ET_FORALL_FLOATHBF16_TYPES(ENUMERATE_TEST_ENTRY)

#undef ENUMERATE_TEST_ENTRY
}
Expand All @@ -64,7 +64,7 @@ class OpDivOutTest : public OperatorTest {
#define ENUMERATE_TEST_ENTRY(ctype, dtype) \
test_div_enumerate_out_types<DTYPE_A, ScalarType::dtype>();

ET_FORALL_REAL_TYPES(ENUMERATE_TEST_ENTRY)
ET_FORALL_REALHBF16_TYPES(ENUMERATE_TEST_ENTRY)

#undef ENUMERATE_TEST_ENTRY
}
Expand Down Expand Up @@ -183,7 +183,7 @@ void OpDivOutTest::test_div_enumerate_a_types() {
#define ENUMERATE_TEST_ENTRY(ctype, dtype) \
test_div_enumerate_b_types<ScalarType::dtype>();

ET_FORALL_REAL_TYPES(ENUMERATE_TEST_ENTRY)
ET_FORALL_REALHBF16_TYPES(ENUMERATE_TEST_ENTRY)

test_div<ScalarType::Bool, ScalarType::Float, ScalarType::Float>();

Expand Down Expand Up @@ -506,9 +506,8 @@ TEST_F(OpDivOutTest, DynamicShapeUpperBoundLargerThanExpected) {
TEST_F(OpDivOutTest, BroadcastNDTest) {
// Test 3D tensors
test_broadcast_3D<ScalarType::Float>();
// half and bfloat16 are not supported for div quite yet
// test_broadcast_3D<ScalarType::Half>();
// test_broadcast_3D<ScalarType::BFloat16>();
test_broadcast_3D<ScalarType::Half>();
test_broadcast_3D<ScalarType::BFloat16>();
}

TEST_F(OpDivOutTest, DynamicShapeUnbound) {
Expand Down
4 changes: 2 additions & 2 deletions kernels/test/op_eq_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class OpEqScalarOutTest : public OperatorTest {

TEST_F(OpEqScalarOutTest, AllRealInputBoolOutputSupport) {
#define TEST_ENTRY(ctype, dtype) test_eq_scalar_out<ScalarType::dtype>();
ET_FORALL_REAL_TYPES(TEST_ENTRY);
ET_FORALL_REALHBF16_TYPES(TEST_ENTRY);
#undef TEST_ENTRY
}

Expand Down Expand Up @@ -100,7 +100,7 @@ TEST_F(OpEqScalarOutTest, AllRealOutputDTypes) {
GTEST_SKIP() << "ATen kernel can handle non-bool output dtype";
}
#define TEST_ENTRY(ctype, dtype) test_eq_all_output_dtypes<ScalarType::dtype>();
ET_FORALL_REAL_TYPES(TEST_ENTRY);
ET_FORALL_REALHBF16_TYPES(TEST_ENTRY);
#undef TEST_ENTRY
}

Expand Down
12 changes: 6 additions & 6 deletions kernels/test/op_ge_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ TEST_F(OpGeScalarOutTest, AllRealInputBoolOutputSupport) {
#define TEST_ENTRY(ctype_in, dtype_in, ctype_out, dtype_out) \
test_ge_scalar_out<ScalarType::dtype_in, ScalarType::dtype_out>();

#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REAL_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REALHBF16_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
test_ge_scalar_out<ScalarType::dtype_in, ScalarType::Bool>();

ET_FORALL_REAL_TYPES(TEST_FORALL_OUT_TYPES)
ET_FORALL_REALHBF16_TYPES(TEST_FORALL_OUT_TYPES)

#undef TEST_FORALL_OUT_TYPES
#undef TEST_ENTRY
Expand Down Expand Up @@ -124,11 +124,11 @@ TEST_F(OpGeTensorOutTest, AllDtypesSupported) {
#define TEST_ENTRY(ctype_in, dtype_in, ctype_out, dtype_out) \
test_dtype<ScalarType::dtype_in, ScalarType::dtype_out>();

#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REAL_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REALHBF16_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
test_dtype<ScalarType::dtype_in, ScalarType::Bool>();

ET_FORALL_REAL_TYPES(TEST_FORALL_OUT_TYPES);
ET_FORALL_REALHBF16_TYPES(TEST_FORALL_OUT_TYPES);

#undef TEST_FORALL_OUT_TYPES
#undef TEST_ENTRY
Expand Down
12 changes: 6 additions & 6 deletions kernels/test/op_gt_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ TEST_F(OpGtScalarOutTest, AllRealInputBoolOutputSupport) {
#define TEST_ENTRY(ctype_in, dtype_in, ctype_out, dtype_out) \
test_gt_scalar_out<ScalarType::dtype_in, ScalarType::dtype_out>();

#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REAL_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REALHBF16_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
test_gt_scalar_out<ScalarType::dtype_in, ScalarType::Bool>();

ET_FORALL_REAL_TYPES(TEST_FORALL_OUT_TYPES)
ET_FORALL_REALHBF16_TYPES(TEST_FORALL_OUT_TYPES)

#undef TEST_FORALL_OUT_TYPES
#undef TEST_ENTRY
Expand Down Expand Up @@ -124,11 +124,11 @@ TEST_F(OpGtTensorOutTest, AllDtypesSupported) {
#define TEST_ENTRY(ctype_in, dtype_in, ctype_out, dtype_out) \
test_dtype<ScalarType::dtype_in, ScalarType::dtype_out>();

#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REAL_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REALHBF16_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
test_dtype<ScalarType::dtype_in, ScalarType::Bool>();

ET_FORALL_REAL_TYPES(TEST_FORALL_OUT_TYPES);
ET_FORALL_REALHBF16_TYPES(TEST_FORALL_OUT_TYPES);

#undef TEST_FORALL_OUT_TYPES
#undef TEST_ENTRY
Expand Down
12 changes: 6 additions & 6 deletions kernels/test/op_le_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ TEST_F(OpLeScalarOutTest, AllRealInputBoolOutputSupport) {
#define TEST_ENTRY(ctype_in, dtype_in, ctype_out, dtype_out) \
test_le_scalar_out<ScalarType::dtype_in, ScalarType::dtype_out>();

#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REAL_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REALHBF16_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
test_le_scalar_out<ScalarType::dtype_in, ScalarType::Bool>();

ET_FORALL_REAL_TYPES(TEST_FORALL_OUT_TYPES)
ET_FORALL_REALHBF16_TYPES(TEST_FORALL_OUT_TYPES)

#undef TEST_FORALL_OUT_TYPES
#undef TEST_ENTRY
Expand Down Expand Up @@ -124,11 +124,11 @@ TEST_F(OpLeTensorOutTest, AllDtypesSupported) {
#define TEST_ENTRY(ctype_in, dtype_in, ctype_out, dtype_out) \
test_dtype<ScalarType::dtype_in, ScalarType::dtype_out>();

#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REAL_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REALHBF16_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
test_dtype<ScalarType::dtype_in, ScalarType::Bool>();

ET_FORALL_REAL_TYPES(TEST_FORALL_OUT_TYPES);
ET_FORALL_REALHBF16_TYPES(TEST_FORALL_OUT_TYPES);

#undef TEST_FORALL_OUT_TYPES
#undef TEST_ENTRY
Expand Down
12 changes: 6 additions & 6 deletions kernels/test/op_lt_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ TEST_F(OpLtScalarOutTest, AllRealInputBoolOutputSupport) {
#define TEST_ENTRY(ctype_in, dtype_in, ctype_out, dtype_out) \
test_lt_scalar_out<ScalarType::dtype_in, ScalarType::dtype_out>();

#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REAL_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REALHBF16_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
test_lt_scalar_out<ScalarType::dtype_in, ScalarType::Bool>();

ET_FORALL_REAL_TYPES(TEST_FORALL_OUT_TYPES)
ET_FORALL_REALHBF16_TYPES(TEST_FORALL_OUT_TYPES)

#undef TEST_FORALL_OUT_TYPES
#undef TEST_ENTRY
Expand Down Expand Up @@ -124,11 +124,11 @@ TEST_F(OpLtTensorOutTest, AllDtypesSupported) {
#define TEST_ENTRY(ctype_in, dtype_in, ctype_out, dtype_out) \
test_dtype<ScalarType::dtype_in, ScalarType::dtype_out>();

#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REAL_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
#define TEST_FORALL_OUT_TYPES(ctype_in, dtype_in) \
ET_FORALL_REALHBF16_TYPES_WITH2(ctype_in, dtype_in, TEST_ENTRY) \
test_dtype<ScalarType::dtype_in, ScalarType::Bool>();

ET_FORALL_REAL_TYPES(TEST_FORALL_OUT_TYPES);
ET_FORALL_REALHBF16_TYPES(TEST_FORALL_OUT_TYPES);

#undef TEST_FORALL_OUT_TYPES
#undef TEST_ENTRY
Expand Down
6 changes: 3 additions & 3 deletions kernels/test/op_ne_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class OpNeScalarOutTest : public OperatorTest {

TEST_F(OpNeScalarOutTest, AllRealInputBoolOutputSupport) {
#define TEST_ENTRY(ctype, dtype) test_ne_scalar_out<ScalarType::dtype>();
ET_FORALL_REAL_TYPES(TEST_ENTRY);
ET_FORALL_REALHBF16_TYPES(TEST_ENTRY);
#undef TEST_ENTRY
}

Expand Down Expand Up @@ -117,13 +117,13 @@ TEST_F(OpNeScalarOutTest, MismatchedShapesDies) {

TEST_F(OpNeScalarOutTest, AllRealOutputDTypesSupported) {
#define TEST_ENTRY(ctype, dtype) test_ne_all_output_dtypes<ScalarType::dtype>();
ET_FORALL_REAL_TYPES(TEST_ENTRY);
ET_FORALL_REALHBF16_TYPES(TEST_ENTRY);
#undef TEST_ENTRY
}

TEST_F(OpNeTest, AllDtypesSupported) {
#define TEST_ENTRY(ctype, dtype) test_dtype<ctype, ScalarType::dtype>();
ET_FORALL_REAL_TYPES(TEST_ENTRY);
ET_FORALL_REALHBF16_TYPES(TEST_ENTRY);
#undef TEST_ENTRY
}

Expand Down
4 changes: 2 additions & 2 deletions kernels/test/op_sub_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class OpSubOutTest : public OperatorTest {
#define ENUMERATE_TEST_ENTRY(ctype, dtype) \
test_sub_enumerate_out_types<DTYPE_A, ScalarType::dtype>();

ET_FORALL_REAL_TYPES_AND(Half, ENUMERATE_TEST_ENTRY)
ET_FORALL_REALHBF16_TYPES(ENUMERATE_TEST_ENTRY)

#undef ENUMERATE_TEST_ENTRY
}
Expand Down Expand Up @@ -208,7 +208,7 @@ class OpSubOutTest : public OperatorTest {
#define ENUMERATE_TEST_ENTRY(ctype, dtype) \
test_sub_enumerate_b_types<ScalarType::dtype>();

ET_FORALL_REAL_TYPES_AND(Half, ENUMERATE_TEST_ENTRY)
ET_FORALL_REALHBF16_TYPES(ENUMERATE_TEST_ENTRY)

#undef ENUMERATE_TEST_ENTRY
}
Expand Down
Loading