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

#include <LogSoftmax.h>

Collaboration diagram for luci_interpreter::kernels::LogSoftmax:

Public Member Functions

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

Constructor & Destructor Documentation

◆ LogSoftmax()

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

Definition at line 30 of file LogSoftmax.cpp.

30: 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::LogSoftmax::configure ( )
overridevirtual

Implements luci_interpreter::Kernel.

Definition at line 32 of file LogSoftmax.cpp.

33{
34 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type());
35 if (input()->element_type() == DataType::U8)
36 {
37 LUCI_INTERPRETER_CHECK(output()->scale() == 16. / 256);
38 LUCI_INTERPRETER_CHECK(output()->zero_point() == 255);
39
40 tflite::SoftmaxParams params{};
41
42 params.table = _table;
43 params.beta = 1.0;
44 luci_interpreter_pal::PopulateSoftmaxLookupTable(&params, input()->scale(), params.beta);
45 }
46 output()->resize(input()->shape());
47}
void resize(const Shape &new_shape)
Definition Tensor.cpp:56
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36

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

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 49 of file LogSoftmax.cpp.

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

References input().

◆ input()

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

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

◆ output()

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

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