MCPcopy Create free account
hub / github.com/OAID/Tengine / prelu_kernel

Function prelu_kernel

executor/operator/arm64/prelu_float.cpp:63–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void prelu_kernel(int i, int id, void* data, const float *input,float *output,float* slope,int channel_size)
64{
65 int step = ((int*)data)[0];
66 float32x4_t _zero = vdupq_n_f32(0.f);
67 for(int c = 0; c < step; c++)
68 {
69 int cur_c = id * step + c;
70 const float* cur_input = input + cur_c * channel_size;
71 float* cur_output = output + cur_c * channel_size;
72 float32x4_t _slope = vdupq_n_f32(slope[cur_c]);
73 for(int l=0; l< (channel_size & -4); l += 4)
74 {
75 float32x4_t _p = vld1q_f32(cur_input);
76 // ri = ai <= bi ? 1...1:0...0
77 uint32x4_t _lemask = vcleq_f32(_p, _zero);
78 float32x4_t _ps = vmulq_f32(_p, _slope);
79 // bitwise select
80 _p = vbslq_f32(_lemask, _ps, _p);
81 vst1q_f32(cur_output, _p);
82 cur_input += 4;
83 cur_output += 4;
84 }
85 for(int l = channel_size & ~3; l < channel_size; l++)
86 {
87 *cur_output = MAX(cur_input[0], 0.f) + slope[cur_c] * MIN(cur_input[0], 0.f);
88 cur_input ++;
89 }
90 }
91}
92
93bool PreluOps::Run(Node* node)
94{

Callers 1

RunMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected