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

#include <Relu6.h>

Collaboration diagram for luci_interpreter::kernels::Relu6:

Public Member Functions

 Relu6 (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 Relu6.h.

Constructor & Destructor Documentation

◆ Relu6()

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

Definition at line 30 of file Relu6.cpp.

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

References input().

Member Function Documentation

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 32 of file Relu6.cpp.

33{
34 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type());
35
36 if (input()->element_type() == DataType::U8)
37 {
38 double multiplier = input()->scale() / output()->scale();
39 quantizeMultiplier(multiplier, &_output_multiplier, &_output_shift);
40 }
41 output()->resize(input()->shape());
42}
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::Relu6::execute ( ) const
overridevirtual

Implements luci_interpreter::Kernel.

Definition at line 44 of file Relu6.cpp.

45{
46 switch (input()->element_type())
47 {
48 case DataType::FLOAT32:
49 evalFloat();
50 break;
51 case DataType::U8:
52 evalQuantized();
53 break;
54 default:
55 throw std::runtime_error("luci-intp Relu6 Unsupported type.");
56 }
57}

References input().

◆ input()

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

Definition at line 32 of file Relu6.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 Relu6().

◆ output()

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

Definition at line 33 of file Relu6.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: