Skip to content

Commit 3f447e7

Browse files
committed
relax tolerances for all unary float ops
We were requiring ourselves to compute at double-precision, but ATen actually converts non-floating-point types to float by default, not double. Use the ATen tolerances everywhere ghstack-source-id: 616326b8931d4b0193a3389b001b4b5afd29be12 ghstack-comment-id: 2751961338 Pull Request resolved: #9585
1 parent 8e23a55 commit 3f447e7

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

kernels/test/UnaryUfuncRealHBBF16ToFloatHBF16Test.h

+8-12
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,16 @@ class UnaryUfuncRealHBBF16ToFloatHBF16Test : public OperatorTest {
7272

7373
auto expected = tf_out.make({1, 6}, expected_vector);
7474
if (IN_DTYPE == ScalarType::BFloat16 || OUT_DTYPE == ScalarType::BFloat16) {
75-
double rtol = executorch::runtime::testing::internal::kDefaultRtol;
76-
// It appears we need a higher tolerance for at least some ATen
77-
// tests, like aten_op_acosh_test.
78-
if (get_supported_features()->is_aten) {
79-
rtol = 3e-3;
80-
}
75+
// Raise tolerance because both we and ATen run these
76+
// computations at internal float32 precision rather than
77+
// float64.
78+
double rtol = 3e-3;
8179
EXPECT_TENSOR_CLOSE_WITH_TOL(out, expected, rtol, executorch::runtime::testing::internal::kDefaultBFloat16Atol);
8280
} else if (IN_DTYPE == ScalarType::Half || OUT_DTYPE == ScalarType::Half) {
83-
double rtol = executorch::runtime::testing::internal::kDefaultRtol;
84-
// It appears we need a higher tolerance for at least some ATen
85-
// tests, like aten_op_acosh_test.
86-
if (get_supported_features()->is_aten) {
87-
rtol = 1e-3;
88-
}
81+
// Raise tolerance because both we and ATen run these
82+
// computations at internal float32 precision rather than
83+
// float64.
84+
double rtol = 1e-3;
8985
EXPECT_TENSOR_CLOSE_WITH_TOL(out, expected, rtol, executorch::runtime::testing::internal::kDefaultHalfAtol);
9086
} else {
9187
EXPECT_TENSOR_CLOSE(out, expected);

0 commit comments

Comments
 (0)