Browse Source

fix mips tanh

tags/20210720
nihui 5 years ago
parent
commit
832fc3eb72
2 changed files with 7 additions and 8 deletions
  1. +4
    -4
      src/layer/mips/mips_mathfun.h
  2. +3
    -4
      src/layer/mips/tanh_mips.cpp

+ 4
- 4
src/layer/mips/mips_mathfun.h View File

@@ -170,11 +170,11 @@ static inline v4f32 tanh_ps(v4f32 x)

// abs(x) > HALFMAXLOGF
// return 1.0 or -1.0
v4i32_w mask_pos = __msa_fcle_w((v4f32)__msa_fill_w(0), x2);
v4f32 y1 = (v4f32)__msa_bsel_v((v16u8)mask_pos, (v16u8)__msa_fill_w(c_1.i), (v16u8)__msa_fill_w(c_n1.i));
v4i32_w mask_pos = __msa_fcle_w((v4f32)__msa_fill_w(0), x);
v4f32 y1 = (v4f32)__msa_bsel_v((v16u8)mask_pos, (v16u8)__msa_fill_w(c_n1.i), (v16u8)__msa_fill_w(c_1.i));

y = (v4f32)__msa_bsel_v((v16u8)mask_l, (v16u8)y0, (v16u8)y);
y = (v4f32)__msa_bsel_v((v16u8)mask_l2, (v16u8)y1, (v16u8)y);
y = (v4f32)__msa_bsel_v((v16u8)mask_l, (v16u8)y, (v16u8)y0);
y = (v4f32)__msa_bsel_v((v16u8)mask_l2, (v16u8)y, (v16u8)y1);
return y;
}



+ 3
- 4
src/layer/mips/tanh_mips.cpp View File

@@ -15,9 +15,8 @@
#include "tanh_mips.h"

#if __mips_msa
#include "mips_mathfun.h"

#include <msa.h>
#include "mips_mathfun.h"
#endif // __mips_msa

#include <math.h>
@@ -36,14 +35,14 @@ int TanH_mips::forward_inplace(Mat& bottom_top_blob, const Option& opt) const
{
float* ptr = bottom_top_blob.channel(q);

#if 0 // __mips_msa
#if __mips_msa
int nn = size >> 2;
int remain = size - (nn << 2);
#else
int remain = size;
#endif // __mips_msa

#if 0 // __mips_msa
#if __mips_msa
for (; nn > 0; nn--)
{
v4f32 _p = (v4f32)__msa_ld_w(ptr, 0);


Loading…
Cancel
Save