File tree Expand file tree Collapse file tree 2 files changed +3
-27
lines changed Expand file tree Collapse file tree 2 files changed +3
-27
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ namespace {
32
32
* T must be a floating point type. Non-floating point data should be compared
33
33
* directly.
34
34
*/
35
- template <typename T>
35
+ template <
36
+ typename T,
37
+ typename = std::enable_if_t <std::is_floating_point<T>::value>>
36
38
bool data_is_close (
37
39
const T* a,
38
40
const T* b,
@@ -108,13 +110,6 @@ bool tensors_are_close(
108
110
a.numel (),
109
111
rtol,
110
112
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);
118
113
} else {
119
114
// Non-floating-point types can be compared bitwise.
120
115
return memcmp (a.const_data_ptr (), b.const_data_ptr (), a.nbytes ()) == 0 ;
@@ -155,13 +150,6 @@ bool tensor_data_is_close(
155
150
a.numel (),
156
151
rtol,
157
152
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);
165
153
} else {
166
154
// Non-floating-point types can be compared bitwise.
167
155
return memcmp (a.const_data_ptr (), b.const_data_ptr (), a.nbytes ()) == 0 ;
Original file line number Diff line number Diff line change @@ -681,18 +681,6 @@ std::ostream& operator<<(std::ostream& out, const Half& value);
681
681
682
682
namespace std {
683
683
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
-
696
684
template <>
697
685
class numeric_limits <torch::executor::Half> {
698
686
public:
You can’t perform that action at this time.
0 commit comments