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

#include <Dequantize.h>

Collaboration diagram for luci_interpreter::kernels::Dequantize:

Public Member Functions

 Dequantize (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 28 of file Dequantize.h.

Constructor & Destructor Documentation

◆ Dequantize()

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

Definition at line 26 of file Dequantize.cpp.

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

References input().

Member Function Documentation

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 28 of file Dequantize.cpp.

29{
30 LUCI_INTERPRETER_CHECK(input()->element_type() == loco::DataType::S8 ||
31 input()->element_type() == loco::DataType::U8 ||
32 input()->element_type() == loco::DataType::S16);
33
34 LUCI_INTERPRETER_CHECK(input()->scales().size() == 1);
35
36 if (input()->element_type() == loco::DataType::S16)
37 LUCI_INTERPRETER_CHECK(input()->zero_point() == 0);
38
39 LUCI_INTERPRETER_CHECK(output()->element_type() == loco::DataType::FLOAT32);
40
41 output()->resize(input()->shape());
42}
void resize(const Shape &new_shape)
Definition Tensor.cpp:56
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
int32_t size[5]
Definition Slice.cpp:35

References input(), LUCI_INTERPRETER_CHECK, output(), luci_interpreter::Tensor::resize(), and size.

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 44 of file Dequantize.cpp.

45{
46 tflite::DequantizationParams op_params;
47 op_params.zero_point = input()->zero_point();
48 op_params.scale = input()->scale();
49
50 switch (input()->element_type())
51 {
52 case loco::DataType::U8:
53 {
54 luci_interpreter_pal::Dequantize(op_params, getTensorShape(input()),
55 getTensorData<uint8_t>(input()), getTensorShape(output()),
56 getTensorData<float>(output()));
57 break;
58 }
59 case loco::DataType::S8:
60 {
61 luci_interpreter_pal::Dequantize(op_params, getTensorShape(input()),
62 getTensorData<int8_t>(input()), getTensorShape(output()),
63 getTensorData<float>(output()));
64 break;
65 }
66 case loco::DataType::S16:
67 {
68 luci_interpreter_pal::Dequantize(op_params, getTensorShape(input()),
69 getTensorData<int16_t>(input()), getTensorShape(output()),
70 getTensorData<float>(output()));
71 break;
72 }
73 default:
74 throw std::runtime_error("luci-intp Dequantize Unsupported type.");
75 }
76}
float scale() const
Definition Tensor.h:109
int32_t zero_point() const
Definition Tensor.h:115
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
Definition Utils.h:194

References luci_interpreter::kernels::getTensorShape(), input(), output(), luci_interpreter::Tensor::scale(), and luci_interpreter::Tensor::zero_point().

◆ input()

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

Definition at line 33 of file Dequantize.h.

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

References luci_interpreter::Kernel::_inputs.

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

◆ output()

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

Definition at line 34 of file Dequantize.h.

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

References luci_interpreter::Kernel::_outputs.

Referenced by configure(), and execute().


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