aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-05-14 04:07:46 -0700
committerHaibo Huang <hhb@google.com>2020-05-15 00:20:18 +0000
commit7cea9a0f2055f812f590716813104a16dd56a367 (patch)
tree30b48e320586c9d4e5beec06e7d903dc3fe55d94
parent2ea5ac4e63f6f5c84d75b8da4ec3d8ad332bc26b (diff)
parent4dfe081cf6bcd15db339cf2680b9281b8451eeb3 (diff)
downloadFP16-7cea9a0f2055f812f590716813104a16dd56a367.tar.gz
Upgrade FP16 to 4dfe081cf6bcd15db339cf2680b9281b8451eeb3
Exempt-From-Owner-Approval: upgrade Change-Id: I2f0b6248a85ce7ac92982ad91f619e84c941f36c
-rw-r--r--METADATA6
-rw-r--r--include/fp16/bitcasts.h16
2 files changed, 19 insertions, 3 deletions
diff --git a/METADATA b/METADATA
index 5d4ed15..437b9ba 100644
--- a/METADATA
+++ b/METADATA
@@ -9,11 +9,11 @@ third_party {
type: GIT
value: "https://github.com/Maratyszcza/FP16"
}
- version: "3c54eacb74f6f5e39077300c5564156c424d77ba"
+ version: "4dfe081cf6bcd15db339cf2680b9281b8451eeb3"
license_type: NOTICE
last_upgrade_date {
year: 2020
- month: 4
- day: 13
+ month: 5
+ day: 14
}
}
diff --git a/include/fp16/bitcasts.h b/include/fp16/bitcasts.h
index 26a755c..86a4e22 100644
--- a/include/fp16/bitcasts.h
+++ b/include/fp16/bitcasts.h
@@ -8,6 +8,14 @@
#include <stdint.h>
#endif
+#if defined(__INTEL_COMPILER)
+ #include <immintrin.h>
+#endif
+
+#if defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
+ #include <intrin.h>
+#endif
+
static inline float fp32_from_bits(uint32_t w) {
#if defined(__OPENCL_VERSION__)
@@ -16,6 +24,8 @@ static inline float fp32_from_bits(uint32_t w) {
return __uint_as_float((unsigned int) w);
#elif defined(__INTEL_COMPILER)
return _castu32_f32(w);
+#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
+ return _CopyFloatFromInt32((__int32) w);
#else
union {
uint32_t as_bits;
@@ -32,6 +42,8 @@ static inline uint32_t fp32_to_bits(float f) {
return (uint32_t) __float_as_uint(f);
#elif defined(__INTEL_COMPILER)
return _castf32_u32(f);
+#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
+ return (uint32_t) _CopyInt32FromFloat(f);
#else
union {
float as_value;
@@ -48,6 +60,8 @@ static inline double fp64_from_bits(uint64_t w) {
return __longlong_as_double((long long) w);
#elif defined(__INTEL_COMPILER)
return _castu64_f64(w);
+#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
+ return _CopyDoubleFromInt64((__int64) w);
#else
union {
uint64_t as_bits;
@@ -64,6 +78,8 @@ static inline uint64_t fp64_to_bits(double f) {
return (uint64_t) __double_as_longlong(f);
#elif defined(__INTEL_COMPILER)
return _castf64_u64(f);
+#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
+ return (uint64_t) _CopyInt64FromDouble(f);
#else
union {
double as_value;