diff options
author | Marat Dukhan <maratek@google.com> | 2022-08-30 07:49:53 -0700 |
---|---|---|
committer | XNNPACK Team <xnnpack-github-robot@google.com> | 2022-08-30 07:50:56 -0700 |
commit | 6fa34a1e4f85cd21f4db69ce4e819d2ce783a42b (patch) | |
tree | fe9db672391b7d4fd09a66ecd7369e1e30e05974 | |
parent | 3ec5444eb709ab1327084969f17cef4cba31606c (diff) | |
download | XNNPACK-6fa34a1e4f85cd21f4db69ce4e819d2ce783a42b.tar.gz |
Add RISC-V and WAsm specializations for math_cvt_sat_u32_f64
PiperOrigin-RevId: 470988725
-rw-r--r-- | src/xnnpack/math.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/xnnpack/math.h b/src/xnnpack/math.h index b461ae219..96f1e778b 100644 --- a/src/xnnpack/math.h +++ b/src/xnnpack/math.h @@ -317,6 +317,14 @@ XNN_INLINE static uint32_t math_cvt_sat_u32_f64(double x) { : [i] "=r" (i) : [x] "w" (x)); return i; + #elif defined(__GNUC__) && defined(__riscv) + uint32_t i; + __asm__ ("fcvt.wu.d %[i], %[x], rne" + : [i] "=r" (i) + : [x] "f" (x)); + return i; + #elif defined(__clang__) && defined(__wasm__) && defined(__wasm_nontrapping_fptoint__) + return __builtin_wasm_trunc_saturate_u_i32_f64(rint(x)); #else x = math_max_f64(x, 0.0); x = math_min_f64(x, 4294967295.0); |