Skip to content

Commit

Permalink
fix floor ceil
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Aug 26, 2024
1 parent 2463454 commit a9f8d24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions src/layer/riscv/unaryop_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,15 @@ 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);
}
};

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);
}
};

Expand Down
8 changes: 2 additions & 6 deletions src/layer/riscv/unaryop_riscv_zvfh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,15 @@ 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);
}
};

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);
}
};

Expand Down

0 comments on commit a9f8d24

Please sign in to comment.