ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::ir::operation::ElementwiseActivation Class Reference

#include <ElementwiseActivation.h>

Collaboration diagram for onert::ir::operation::ElementwiseActivation:

Data Structures

struct  Param
 

Public Types

enum  Input { INPUT = 0 }
 
enum class  Type {
  ELU , LOGISTIC , RELU , TANH ,
  LEAKY_RELU
}
 

Public Member Functions

 ElementwiseActivation (const OperandIndexSequence &inputs, const OperandIndexSequence &outputs, const Param &param)
 
void accept (OperationVisitor &v) const override
 
std::string name () const override
 
OpCode opcode () const final
 
const Paramparam () const
 
- Public Member Functions inherited from onert::ir::Operation
 Operation (OperandConstraint input_constr, const OperandIndexSequence &inputs, const OperandIndexSequence &outputs, OperandConstraint output_constr=OperandConstraint::createAny())
 
 Operation (OperandConstraint input_constr, OperandConstraint output_constr=OperandConstraint::createAny())
 
 Operation (const Operation &)=default
 
 Operation (Operation &&)=default
 
Operationoperator= (const Operation &)=default
 
Operationoperator= (Operation &&)=default
 
virtual ~Operation ()
 
void replaceInputs (const OperandIndex &from, const OperandIndex &to) override
 
void replaceOutputs (const OperandIndex &from, const OperandIndex &to) override
 
OperandIndexSequencegetInputs ()
 
const OperandIndexSequencegetInputs () const override
 
const OperandIndexSequencegetOutputs () const override
 
void setInputs (const OperandIndexSequence &indexes)
 
void setOutputs (const OperandIndexSequence &indexes)
 
- Public Member Functions inherited from onert::ir::IOperation
virtual ~IOperation ()=default
 

Static Public Attributes

static float infinity = std::numeric_limits<float>::infinity()
 

Detailed Description

Definition at line 29 of file ElementwiseActivation.h.

Member Enumeration Documentation

◆ Input

◆ Type

Constructor & Destructor Documentation

◆ ElementwiseActivation()

onert::ir::operation::ElementwiseActivation::ElementwiseActivation ( const OperandIndexSequence inputs,
const OperandIndexSequence outputs,
const Param param 
)

Definition at line 31 of file ElementwiseActivation.cc.

35{
37 {
38 assert(param.alpha == 0.0f && param.beta == 0.0f &&
39 "Logistic will be supported only as "
40 "sigmoid function(L=1, k=1, x0=0). So, do "
41 "not use alpha and beta");
42 }
43 else if (param.op_type == Type::RELU)
44 {
45 assert(param.alpha >= param.beta && "ReLU's alpha must be equal or greater than beta");
46 }
47 else if (param.op_type == Type::TANH)
48 {
49 assert(param.alpha == 1.0f && param.beta == 1.0f &&
50 "f(x) = alpha * tanh(beta * x), Tanh is "
51 "supported only the values of alpha and "
52 "beta are 1.f");
53 }
54}
static OperandConstraint createExact(uint32_t exact)

References onert::ir::operation::ElementwiseActivation::Param::alpha, onert::ir::operation::ElementwiseActivation::Param::beta, LOGISTIC, onert::ir::operation::ElementwiseActivation::Param::op_type, param(), RELU, and TANH.

Member Function Documentation

◆ accept()

void onert::ir::operation::ElementwiseActivation::accept ( OperationVisitor v) const
overridevirtual

Implements onert::ir::IOperation.

Reimplemented in onert::ir::train::operation::ElementwiseActivation.

Definition at line 29 of file ElementwiseActivation.cc.

29{ v.visit(*this); }

◆ name()

std::string onert::ir::operation::ElementwiseActivation::name ( ) const
overridevirtual

Reimplemented from onert::ir::IOperation.

Definition at line 56 of file ElementwiseActivation.cc.

57{
59 static const std::unordered_map<Type, std::string> name_map{
60 {ElementwiseActivationType::ELU, "ELU"},
61 {ElementwiseActivationType::LOGISTIC, "Logistic"},
62 {ElementwiseActivationType::RELU, "ReLU"},
63 {ElementwiseActivationType::TANH, "Tanh"},
64 {ElementwiseActivationType::LEAKY_RELU, "LeakyRelu"}};
65 return name_map.at(_param.op_type);
66}

References onert::ir::operation::ElementwiseActivation::Param::op_type.

◆ opcode()

OpCode onert::ir::operation::ElementwiseActivation::opcode ( ) const
inlinefinalvirtual

Implements onert::ir::IOperation.

Definition at line 61 of file ElementwiseActivation.h.

61{ return OpCode::ElementwiseActivation; }

◆ param()

Field Documentation

◆ infinity

float onert::ir::operation::ElementwiseActivation::infinity = std::numeric_limits<float>::infinity()
static

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