ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci_interpreter::kernels::LeakyRelu Class Reference

#include <LeakyRelu.h>

Collaboration diagram for luci_interpreter::kernels::LeakyRelu:

Public Member Functions

 LeakyRelu (const Tensor *input, Tensor *output, const LeakyReluParams &params)
 
const Tensorinput () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
- Public Member Functions inherited from luci_interpreter::KernelWithParams< LeakyReluParams >
const LeakyReluParamsparams () const
 
- Public Member Functions inherited from luci_interpreter::Kernel
virtual ~Kernel ()=default
 
const std::vector< const Tensor * > & getInputTensors () const
 
const std::vector< Tensor * > & getOutputTensors () const
 

Additional Inherited Members

- Protected Member Functions inherited from luci_interpreter::KernelWithParams< LeakyReluParams >
 KernelWithParams (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs, const LeakyReluParams &params)
 
- Protected Member Functions inherited from luci_interpreter::Kernel
 Kernel (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs)
 
- Protected Attributes inherited from luci_interpreter::KernelWithParams< LeakyReluParams >
const LeakyReluParams _params
 
- Protected Attributes inherited from luci_interpreter::Kernel
const std::vector< const Tensor * > _inputs
 
const std::vector< Tensor * > _outputs
 

Detailed Description

Definition at line 28 of file LeakyRelu.h.

Constructor & Destructor Documentation

◆ LeakyRelu()

luci_interpreter::kernels::LeakyRelu::LeakyRelu ( const Tensor input,
Tensor output,
const LeakyReluParams params 
)

Definition at line 33 of file LeakyRelu.cpp.

34 : KernelWithParams<LeakyReluParams>({input}, {output}, params)
35{
36}
const LeakyReluParams & params() const
Definition Kernel.h:67
const Tensor * input() const
Definition LeakyRelu.h:33

References input().

Member Function Documentation

◆ configure()

void luci_interpreter::kernels::LeakyRelu::configure ( )
overridevirtual

Implements luci_interpreter::Kernel.

Definition at line 38 of file LeakyRelu.cpp.

39{
40 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type());
41 if (input()->element_type() == DataType::U8)
42 {
43 double alpha_multiplier = input()->scale() * params().alpha / output()->scale();
44 quantizeMultiplier(alpha_multiplier, &_output_multiplier_alpha, &_output_shift_alpha);
45 double identity_multiplier = input()->scale() / output()->scale();
46 quantizeMultiplier(identity_multiplier, &_output_multiplier_identity, &_output_shift_identity);
47 }
48 output()->resize(input()->shape());
49}
void resize(const Shape &new_shape)
Definition Tensor.cpp:56
float scale() const
Definition Tensor.h:109
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
void quantizeMultiplier(double double_multiplier, int32_t *quantized_multiplier, int *shift)
Definition Utils.cpp:157

References luci_interpreter::LeakyReluParams::alpha, input(), LUCI_INTERPRETER_CHECK, output(), luci_interpreter::KernelWithParams< LeakyReluParams >::params(), luci_interpreter::kernels::quantizeMultiplier(), luci_interpreter::Tensor::resize(), and luci_interpreter::Tensor::scale().

◆ execute()

void luci_interpreter::kernels::LeakyRelu::execute ( ) const
overridevirtual

Implements luci_interpreter::Kernel.

Definition at line 51 of file LeakyRelu.cpp.

52{
53 switch (input()->element_type())
54 {
55 case DataType::FLOAT32:
56 evalFloat();
57 break;
58 case DataType::U8:
59 evalQuantized();
60 break;
61 default:
62 throw std::runtime_error("luci-intp LeakyRelu Unsupported type.");
63 }
64}

References input().

◆ input()

const Tensor * luci_interpreter::kernels::LeakyRelu::input ( ) const
inline

Definition at line 33 of file LeakyRelu.h.

33{ return _inputs[0]; }
const std::vector< const Tensor * > _inputs
Definition Kernel.h:52

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), execute(), and LeakyRelu().

◆ output()

Tensor * luci_interpreter::kernels::LeakyRelu::output ( ) const
inline

Definition at line 34 of file LeakyRelu.h.

34{ return _outputs[0]; }
const std::vector< Tensor * > _outputs
Definition Kernel.h:53

References luci_interpreter::Kernel::_outputs.

Referenced by configure().


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