Skip to content

Commit 8602e9e

Browse files
NingLiu006facebook-github-bot
authored andcommitted
Revert D54538932: Enable tensor closeness check for additional types
Differential Revision: D54538932 Original commit changeset: 14d36f2bdcde Original Phabricator Diff: D54538932 fbshipit-source-id: f7092646e852d6f45ec38fedc2635befcc384ea4
1 parent 187079e commit 8602e9e

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

runtime/core/exec_aten/testing_util/tensor_util.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ namespace {
3232
* T must be a floating point type. Non-floating point data should be compared
3333
* directly.
3434
*/
35-
template <typename T>
35+
template <
36+
typename T,
37+
typename = std::enable_if_t<std::is_floating_point<T>::value>>
3638
bool data_is_close(
3739
const T* a,
3840
const T* b,
@@ -108,13 +110,6 @@ bool tensors_are_close(
108110
a.numel(),
109111
rtol,
110112
atol);
111-
} else if (a.scalar_type() == ScalarType::Half) {
112-
return data_is_close<Half>(
113-
a.const_data_ptr<Half>(),
114-
b.const_data_ptr<Half>(),
115-
a.numel(),
116-
rtol,
117-
atol);
118113
} else {
119114
// Non-floating-point types can be compared bitwise.
120115
return memcmp(a.const_data_ptr(), b.const_data_ptr(), a.nbytes()) == 0;
@@ -155,13 +150,6 @@ bool tensor_data_is_close(
155150
a.numel(),
156151
rtol,
157152
atol);
158-
} else if (a.scalar_type() == ScalarType::Half) {
159-
return data_is_close<Half>(
160-
a.const_data_ptr<Half>(),
161-
b.const_data_ptr<Half>(),
162-
a.numel(),
163-
rtol,
164-
atol);
165153
} else {
166154
// Non-floating-point types can be compared bitwise.
167155
return memcmp(a.const_data_ptr(), b.const_data_ptr(), a.nbytes()) == 0;

runtime/core/portable_type/half.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -681,18 +681,6 @@ std::ostream& operator<<(std::ostream& out, const Half& value);
681681

682682
namespace std {
683683

684-
static inline int isinf(torch::executor::Half value) {
685-
return (value.x & 0x7FFF) == 0x7C00;
686-
}
687-
688-
static inline int isnan(torch::executor::Half value) {
689-
return ((value.x & 0x7C00) == 0x7C00) && ((value.x & 0x03ff) != 0);
690-
}
691-
692-
static inline int isfinite(torch::executor::Half value) {
693-
return !(isinf(value) || isnan(value));
694-
}
695-
696684
template <>
697685
class numeric_limits<torch::executor::Half> {
698686
public:

0 commit comments

Comments
 (0)