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

#include <Relu.h>

Collaboration diagram for luci_interpreter::kernels::Relu:

Public Member Functions

 Relu (const Tensor *input, Tensor *output)
 
const Tensorinput () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
- 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::Kernel
 Kernel (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs)
 
- Protected Attributes inherited from luci_interpreter::Kernel
const std::vector< const Tensor * > _inputs
 
const std::vector< Tensor * > _outputs
 

Detailed Description

Definition at line 27 of file Relu.h.

Constructor & Destructor Documentation

◆ Relu()

luci_interpreter::kernels::Relu::Relu ( const Tensor input,
Tensor output 
)

Definition at line 30 of file Relu.cpp.

30: Kernel({input}, {output}) {}
Kernel(std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs)
Definition Kernel.h:31
Tensor * output() const
Definition Relu.h:33
const Tensor * input() const
Definition Relu.h:32

References input().

Member Function Documentation

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 32 of file Relu.cpp.

33{
34 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type());
35 if (input()->element_type() == DataType::S16)
36 {
37 LUCI_INTERPRETER_CHECK(input()->zero_point() == 0 && output()->zero_point() == 0);
38 }
39
40 if (input()->element_type() == DataType::U8 || input()->element_type() == DataType::S16)
41 {
42 double multiplier = input()->scale() / output()->scale();
43 quantizeMultiplier(multiplier, &_output_multiplier, &_output_shift);
44 }
45 output()->resize(input()->shape());
46}
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 input(), LUCI_INTERPRETER_CHECK, output(), luci_interpreter::kernels::quantizeMultiplier(), luci_interpreter::Tensor::resize(), and luci_interpreter::Tensor::scale().

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 48 of file Relu.cpp.

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

References input().

◆ input()

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

Definition at line 32 of file Relu.h.

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

References luci_interpreter::Kernel::_inputs.

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

◆ output()

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

Definition at line 33 of file Relu.h.

33{ 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: