From a9f8d244476d5f9b6870a9c1a62079d7d8027c0d Mon Sep 17 00:00:00 2001 From: nihuini Date: Mon, 26 Aug 2024 17:13:11 +0800 Subject: [PATCH] fix floor ceil --- src/layer/riscv/unaryop_riscv.cpp | 8 ++------ src/layer/riscv/unaryop_riscv_zvfh.cpp | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/layer/riscv/unaryop_riscv.cpp b/src/layer/riscv/unaryop_riscv.cpp index 959751842598..677b8b678ed4 100644 --- a/src/layer/riscv/unaryop_riscv.cpp +++ b/src/layer/riscv/unaryop_riscv.cpp @@ -88,9 +88,7 @@ struct unary_op_floor { vfloat32m8_t operator()(const vfloat32m8_t& x, const size_t& vl) const { - vint32m8_t _xi = __riscv_vfcvt_x_f_v_i32m8(x, vl); - vbool4_t _mask = __riscv_vmfgt_vv_f32m8_b4(__riscv_vfcvt_f_x_v_f32m8(_xi, vl), x, vl); - return __riscv_vfcvt_f_x_v_f32m8(__riscv_vsub_vx_i32m8_m(_mask, _xi, 1, vl), vl); + return __riscv_vfcvt_f_x_v_f32m8(__riscv_vfcvt_x_f_v_i32m8_rm(x, __RISCV_FRM_RDN, vl), vl); } }; @@ -98,9 +96,7 @@ struct unary_op_ceil { vfloat32m8_t operator()(const vfloat32m8_t& x, const size_t& vl) const { - vint32m8_t _xi = __riscv_vfcvt_x_f_v_i32m8(x, vl); - vbool4_t _mask = __riscv_vmflt_vv_f32m8_b4(__riscv_vfcvt_f_x_v_f32m8(_xi, vl), x, vl); - return __riscv_vfcvt_f_x_v_f32m8(__riscv_vadd_vx_i32m8_m(_mask, _xi, 1, vl), vl); + return __riscv_vfcvt_f_x_v_f32m8(__riscv_vfcvt_x_f_v_i32m8_rm(x, __RISCV_FRM_RUP, vl), vl); } }; diff --git a/src/layer/riscv/unaryop_riscv_zvfh.cpp b/src/layer/riscv/unaryop_riscv_zvfh.cpp index 11890dceb7f5..b66e19265c8b 100644 --- a/src/layer/riscv/unaryop_riscv_zvfh.cpp +++ b/src/layer/riscv/unaryop_riscv_zvfh.cpp @@ -81,9 +81,7 @@ struct unary_op_floor_fp16s { vfloat16m8_t operator()(const vfloat16m8_t& x, const size_t& vl) const { - vint16m8_t _xi = __riscv_vfcvt_x_f_v_i16m8(x, vl); - vbool2_t _mask = __riscv_vmfgt_vv_f16m8_b2(__riscv_vfcvt_f_x_v_f16m8(_xi, vl), x, vl); - return __riscv_vfcvt_f_x_v_f16m8(__riscv_vsub_vx_i16m8_m(_mask, _xi, 1, vl), vl); + return __riscv_vfcvt_f_x_v_f16m8(__riscv_vfcvt_x_f_v_i16m8_rm(x, __RISCV_FRM_RDN, vl), vl); } }; @@ -91,9 +89,7 @@ struct unary_op_ceil_fp16s { vfloat16m8_t operator()(const vfloat16m8_t& x, const size_t& vl) const { - vint16m8_t _xi = __riscv_vfcvt_x_f_v_i16m8(x, vl); - vbool2_t _mask = __riscv_vmflt_vv_f16m8_b2(__riscv_vfcvt_f_x_v_f16m8(_xi, vl), x, vl); - return __riscv_vfcvt_f_x_v_f16m8(__riscv_vadd_vx_i16m8_m(_mask, _xi, 1, vl), vl); + return __riscv_vfcvt_f_x_v_f16m8(__riscv_vfcvt_x_f_v_i16m8_rm(x, __RISCV_FRM_RUP, vl), vl); } };