-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbfloat16.h
36 lines (30 loc) · 854 Bytes
/
bfloat16.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include <cstdint>
struct BFloat16 final {
BFloat16() = delete;
BFloat16(float){};
BFloat16(uint16_t){};
BFloat16& operator+=(const BFloat16& rhs);
BFloat16& operator-=(const BFloat16& rhs);
BFloat16& operator*=(const BFloat16& rhs);
BFloat16& operator/=(const BFloat16& rhs);
bool operator<(const BFloat16&) const {
return true; /* stub */
}
bool operator>(const BFloat16& rhs) const {
return rhs < *this;
}
bool operator<=(const BFloat16& rhs) const {
return !(*this > rhs);
}
bool operator>=(const BFloat16& rhs) const {
return !(*this < rhs);
}
bool operator==(const BFloat16&) const {
return true; /* do actual comparison */
}
bool operator!=(const BFloat16& rhs) const {
return !(*this == rhs);
}
friend std::ostream& operator<<(std::ostream&, const BFloat16&);
};