Skip to content

Commit

Permalink
requantize: Use activation_ss in fused_activation.h (#5245)
Browse files Browse the repository at this point in the history
Which fixes int8 requantization on risc-v

Signed-off-by: Molly Sophia <[email protected]>
  • Loading branch information
MollySophia authored Dec 24, 2023
1 parent d1d9aa2 commit 92d49e1
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions src/layer/requantize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// specific language governing permissions and limitations under the License.

#include "requantize.h"
#include "fused_activation.h"

namespace ncnn {

Expand All @@ -25,38 +26,6 @@ static inline signed char float2int8(float v)
return (signed char)int32;
}

static inline float activation_ss(float v, int activation_type, const ncnn::Mat& activation_params)
{
if (activation_type == 1)
{
v = fmaxf(v, 0.f);
}
else if (activation_type == 2)
{
float slope = activation_params[0];
v = v > 0.f ? v : v * slope;
}
else if (activation_type == 3)
{
float min = activation_params[0];
float max = activation_params[1];
if (v < min)
v = min;
if (v > max)
v = max;
}
else if (activation_type == 4)
{
v = 1.f / (1.f + expf(-v));
}
else if (activation_type == 5)
{
v = v * tanhf(logf(expf(v) + 1.f));
}

return v;
}

Requantize::Requantize()
{
one_blob_only = true;
Expand Down

0 comments on commit 92d49e1

Please sign in to comment.