ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw::cker::ActivationFunctor Class Reference

#include <PortableTensorUtils.h>

Public Member Functions

 ActivationFunctor (FusedActivationFunctionType act)
 
float operator() (float a) const
 

Detailed Description

Definition at line 33 of file PortableTensorUtils.h.

Constructor & Destructor Documentation

◆ ActivationFunctor()

nnfw::cker::ActivationFunctor::ActivationFunctor ( FusedActivationFunctionType  act)
inlineexplicit

Definition at line 36 of file PortableTensorUtils.h.

36: act_(act) {}

Member Function Documentation

◆ operator()()

float nnfw::cker::ActivationFunctor::operator() ( float  a) const
inline

Definition at line 38 of file PortableTensorUtils.h.

39 {
40 switch (act_)
41 {
43 return a;
45 return a < 0.f ? 0.f : a;
47 return std::max(0.f, std::min(a, 6.f));
49 return std::tanh(a);
51 return 1.0f / (1.0f + std::exp(-a));
52 default:
53 // TODO(aselle): More informative fatal error!
54 exit(1);
55 }
56 }

References nnfw::cker::kNone, nnfw::cker::kRelu, nnfw::cker::kRelu6, nnfw::cker::kSigmoid, and nnfw::cker::kTanh.


The documentation for this class was generated from the following file: