Skip to content

Commit

Permalink
mips fix
Browse files Browse the repository at this point in the history
  • Loading branch information
brightening-eyes committed Sep 3, 2023
1 parent 6dccf37 commit b36ea45
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/layer/loongarch/unaryop_loongarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,18 +433,17 @@ __m128 ones = (__m128)__lsx_vreplfr2vr_s(1.0f);
__m128 a5 = (__m128)__lsx_vreplfr2vr_s(1.061405429f);
__m128 p = (__m128)__lsx_vreplfr2vr_s(0.3275911f);
__m128 x2 = (__m128)__lsx_vbitclri_w((__m128i)x, 31);
__m128i tiny_mask = __lsx_vfcmp_clt_s((__m128)x2, (__m128)(__m128)__lsx_vreplgr2vr_w(c_tanh_tiny.i));
__m128i sig_mask = __lsx_vreplgr2vr_w(1 << 31);
__m128i s = __lsx_vand_v((__m128i)x, sig_mask);
__m128 x_abs = (__m128)__lsx_vbitclri_w(x, 31);
__m128 t = (__m128)__lsx_vfdiv_s(ones, __lsx_vfadd_s(__lsx_vfmul_s(x_abs, p)));
__m128 t = (__m128)__lsx_vfdiv_s(ones, __lsx_vfadd_s(ones, __lsx_vfmul_s(x_abs, p)));
__m128 y = __lsx_vfsub_s(__lsx_vfmul_s(__lsx_vfmul_s(a5, t), t), __lsx_vfmul_s(__lsx_vfmul_s(a4, t), t));
y = __lsx_vfsub_s(y, __lsx_vfsub_s(__lsx_vfsub_s(a3, t), t));
y = __lsx_vfsub_s(y, __lsx_vfmul_s(__lsx_vfmul_s(a2, t), t));
y = __lsx_vfsub_s(y, __lsx_vfsub_s(__lsx_vfmul_s(a1, t), t));
y = __lsx_vfmul_s(y, t);
y = __lsx_vfmul_s(y, exp_ps(-__lsx_vfmul_s(x_abs, x_abs)));
return (__m128)__lsx_vfmul_s(x, y);
return (__m128)__lsx_vfmul_s(s, y);
}
#endif // __loongarch_sx
};
Expand Down
4 changes: 2 additions & 2 deletions src/layer/mips/unaryop_mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,11 @@ struct unary_op_trunc
#endif // __mips_msa
};

struct unary_op_sin
struct unary_op_erf
{
float func(const float& x) const
{
return (float)sin(x);
return (float)erf(x);
}
#if __mips_msa
v4f32 func_pack4(const v4f32& x) const
Expand Down

0 comments on commit b36ea45

Please sign in to comment.