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

#include <L2Normalize.h>

Collaboration diagram for luci_interpreter::kernels::L2Normalize:

Public Member Functions

 L2Normalize (const Tensor *input, Tensor *output, const L2NormParams &params)
 
const Tensorinput () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
- Public Member Functions inherited from luci_interpreter::KernelWithParams< L2NormParams >
const L2NormParamsparams () 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< L2NormParams >
 KernelWithParams (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs, const L2NormParams &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< L2NormParams >
const L2NormParams _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 L2Normalize.h.

Constructor & Destructor Documentation

◆ L2Normalize()

L2Normalize::L2Normalize ( const Tensor input,
Tensor output,
const L2NormParams params 
)

Definition at line 30 of file L2Normalize.cpp.

31 : KernelWithParams<L2NormParams>({input}, {output}, params)
32{
33}
const L2NormParams & params() const
Definition Kernel.h:67

References input().

Member Function Documentation

◆ configure()

void L2Normalize::configure ( )
overridevirtual

Implements luci_interpreter::Kernel.

Definition at line 35 of file L2Normalize.cpp.

36{
37 LUCI_INTERPRETER_CHECK(input()->shape().num_dims() <= 4);
38 LUCI_INTERPRETER_CHECK(output()->element_type() == DataType::FLOAT32 ||
39 output()->element_type() == DataType::U8);
40 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type());
41 if (output()->element_type() == DataType::U8)
42 {
43 LUCI_INTERPRETER_CHECK(output()->scale() == (1. / 128.));
44 LUCI_INTERPRETER_CHECK(output()->zero_point() == 128);
45 }
46 LUCI_INTERPRETER_CHECK(params().activation == Activation::NONE);
47 output()->resize(input()->shape());
48}
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(), luci_interpreter::KernelWithParams< L2NormParams >::params(), and luci_interpreter::Tensor::resize().

◆ execute()

void L2Normalize::execute ( ) const
overridevirtual

Implements luci_interpreter::Kernel.

Definition at line 50 of file L2Normalize.cpp.

51{
52 switch (output()->element_type())
53 {
54 case DataType::FLOAT32:
55 eval<float>(0);
56 break;
57 case DataType::U8:
58 eval<uint8_t>(input()->zero_point());
59 break;
60 default:
61 throw std::runtime_error("luci-intp L2Normalize Unsupported type.");
62 }
63}

References input(), and output().

◆ input()

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

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

◆ output()

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

Definition at line 34 of file L2Normalize.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: