Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed May 8, 2024
1 parent 00b096f commit ee36857
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/layer/arm/gru_int8.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,18 @@ static void gru_transform_weight_int8(const Mat& weight_xc, const Mat& weight_xc
_reciprocal_xc_R0 = vmulq_f32(vrecpsq_f32(_xc_R0, _reciprocal_xc_R0), _reciprocal_xc_R0);
_reciprocal_xc_U0 = vmulq_f32(vrecpsq_f32(_xc_U0, _reciprocal_xc_U0), _reciprocal_xc_U0);
_reciprocal_xc_N0 = vmulq_f32(vrecpsq_f32(_xc_N0, _reciprocal_xc_N0), _reciprocal_xc_N0);
_reciprocal_xc_R0 = vmulq_f32(vrecpsq_f32(_xc_R0, _reciprocal_xc_R0), _reciprocal_xc_R0);
_reciprocal_xc_U0 = vmulq_f32(vrecpsq_f32(_xc_U0, _reciprocal_xc_U0), _reciprocal_xc_U0);
_reciprocal_xc_N0 = vmulq_f32(vrecpsq_f32(_xc_N0, _reciprocal_xc_N0), _reciprocal_xc_N0);
float32x4_t _reciprocal_hc_R0 = vrecpeq_f32(_hc_R0);
float32x4_t _reciprocal_hc_U0 = vrecpeq_f32(_hc_U0);
float32x4_t _reciprocal_hc_N0 = vrecpeq_f32(_hc_N0);
_reciprocal_hc_R0 = vmulq_f32(vrecpsq_f32(_hc_R0, _reciprocal_hc_R0), _reciprocal_hc_R0);
_reciprocal_hc_U0 = vmulq_f32(vrecpsq_f32(_hc_U0, _reciprocal_hc_U0), _reciprocal_hc_U0);
_reciprocal_hc_N0 = vmulq_f32(vrecpsq_f32(_hc_N0, _reciprocal_hc_N0), _reciprocal_hc_N0);
_reciprocal_hc_R0 = vmulq_f32(vrecpsq_f32(_hc_R0, _reciprocal_hc_R0), _reciprocal_hc_R0);
_reciprocal_hc_U0 = vmulq_f32(vrecpsq_f32(_hc_U0, _reciprocal_hc_U0), _reciprocal_hc_U0);
_reciprocal_hc_N0 = vmulq_f32(vrecpsq_f32(_hc_N0, _reciprocal_hc_N0), _reciprocal_hc_N0);
#endif

vst1q_f32(descales_ptr, _reciprocal_xc_R0);
Expand Down
2 changes: 1 addition & 1 deletion src/layer/arm/neon_mathfun.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static inline float32x4_t div_ps(float32x4_t a, float32x4_t b)
#else
float32x4_t reciprocal = vrecpeq_f32(b);
reciprocal = vmulq_f32(vrecpsq_f32(b, reciprocal), reciprocal);
// reciprocal = vmulq_f32(vrecpsq_f32(b, reciprocal), reciprocal);
reciprocal = vmulq_f32(vrecpsq_f32(b, reciprocal), reciprocal);
return vmulq_f32(a, reciprocal);
#endif
}
Expand Down
2 changes: 2 additions & 0 deletions src/layer/arm/rnn_int8.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ static void rnn_transform_weight_int8(const Mat& weight_xc, const Mat& weight_xc
#else
float32x4_t _reciprocal_xc = vrecpeq_f32(_xc);
_reciprocal_xc = vmulq_f32(vrecpsq_f32(_xc, _reciprocal_xc), _reciprocal_xc);
_reciprocal_xc = vmulq_f32(vrecpsq_f32(_xc, _reciprocal_xc), _reciprocal_xc);
float32x4_t _reciprocal_hc = vrecpeq_f32(_hc);
_reciprocal_hc = vmulq_f32(vrecpsq_f32(_hc, _reciprocal_hc), _reciprocal_hc);
_reciprocal_hc = vmulq_f32(vrecpsq_f32(_hc, _reciprocal_hc), _reciprocal_hc);
#endif

vst1q_f32(descales_ptr, _reciprocal_xc);
Expand Down
4 changes: 2 additions & 2 deletions tests/test_rnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ int test_rnn_int8_with_hidden(const ncnn::Mat& a, int outch, int direction)
weights[4] = RandomMat(outch * num_directions, 100.f, 200.f);

// initial hidden state
ncnn::Mat hidden = RandomMat(outch, num_directions);
ncnn::Mat hidden = RandomMat(outch, num_directions, -1.f, 1.f);

std::vector<ncnn::Mat> as(2);
as[0] = a;
Expand Down Expand Up @@ -329,7 +329,7 @@ int test_rnn_int8_with_hidden_input(const ncnn::Mat& a, int outch, int direction
weights[4] = RandomMat(outch * num_directions, 100.f, 200.f);

// initial hidden state
ncnn::Mat hidden = RandomMat(outch, num_directions);
ncnn::Mat hidden = RandomMat(outch, num_directions, -1.f, 1.f);

std::vector<ncnn::Mat> as(2);
as[0] = a;
Expand Down

0 comments on commit ee36857

Please sign in to comment.