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

#include <InstanceNorm.h>

Collaboration diagram for luci_interpreter::kernels::InstanceNorm:

Public Member Functions

 InstanceNorm (const Tensor *input, const Tensor *gamma, const Tensor *beta, Tensor *output, const InstanceNormParams &params)
 
const Tensorinput () const
 
const Tensorgamma () const
 
const Tensorbeta () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
 InstanceNorm (const Tensor *input, const Tensor *gamma, const Tensor *beta, Tensor *output, const InstanceNormParams &params)
 
const Tensorinput () const
 
const Tensorgamma () const
 
const Tensorbeta () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
- Public Member Functions inherited from luci_interpreter::KernelWithParams< InstanceNormParams >
const InstanceNormParamsparams () 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< InstanceNormParams >
 KernelWithParams (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs, const InstanceNormParams &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< InstanceNormParams >
const InstanceNormParams _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 InstanceNorm.h.

Constructor & Destructor Documentation

◆ InstanceNorm() [1/2]

luci_interpreter::kernels::InstanceNorm::InstanceNorm ( const Tensor input,
const Tensor gamma,
const Tensor beta,
Tensor output,
const InstanceNormParams params 
)

Definition at line 29 of file InstanceNorm.cpp.

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

References beta(), gamma(), and input().

◆ InstanceNorm() [2/2]

luci_interpreter::kernels::InstanceNorm::InstanceNorm ( const Tensor input,
const Tensor gamma,
const Tensor beta,
Tensor output,
const InstanceNormParams params 
)

Member Function Documentation

◆ beta() [1/2]

const Tensor * luci_interpreter::kernels::InstanceNorm::beta ( ) const
inline

Definition at line 36 of file InstanceNorm.h.

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

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), and InstanceNorm().

◆ beta() [2/2]

const Tensor * luci_interpreter::kernels::InstanceNorm::beta ( ) const
inline

Definition at line 36 of file InstanceNorm.h.

36{ return _inputs[2]; }

References luci_interpreter::Kernel::_inputs.

◆ configure() [1/2]

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

Implements luci_interpreter::Kernel.

Definition at line 35 of file InstanceNorm.cpp.

36{
37 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type());
38 LUCI_INTERPRETER_CHECK(gamma()->element_type() == input()->element_type());
39 if (input()->shape().num_dims() == 4)
40 {
41 LUCI_INTERPRETER_CHECK(input()->shape().num_dims() == 4);
42 LUCI_INTERPRETER_CHECK(gamma()->shape().num_dims() == 1);
43 LUCI_INTERPRETER_CHECK(gamma()->shape().dim(0) == input()->shape().dim(3) ||
44 gamma()->shape().dim(0) == 1);
45 LUCI_INTERPRETER_CHECK(beta()->element_type() == input()->element_type());
46 LUCI_INTERPRETER_CHECK(beta()->shape().num_dims() == 1);
47 LUCI_INTERPRETER_CHECK(beta()->shape().dim(0) == input()->shape().dim(3) ||
48 beta()->shape().dim(0) == 1);
49 }
50 else if (input()->shape().num_dims() == 3)
51 {
52 LUCI_INTERPRETER_CHECK(input()->shape().num_dims() == 3);
53 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type());
54 LUCI_INTERPRETER_CHECK(gamma()->element_type() == input()->element_type());
55 LUCI_INTERPRETER_CHECK(gamma()->shape().num_dims() == 1);
56 LUCI_INTERPRETER_CHECK(gamma()->shape().dim(0) == input()->shape().dim(1) ||
57 gamma()->shape().dim(0) == 1);
58 LUCI_INTERPRETER_CHECK(beta()->element_type() == input()->element_type());
59 LUCI_INTERPRETER_CHECK(beta()->shape().num_dims() == 1);
60 LUCI_INTERPRETER_CHECK(beta()->shape().dim(0) == input()->shape().dim(1) ||
61 beta()->shape().dim(0) == 1);
62 }
63 else
64 LUCI_INTERPRETER_CHECK(false && "luci-intp InstanceNorm unsupported rank.");
65
66 output()->resize(input()->shape());
67}
void resize(const Shape &new_shape)
Definition Tensor.cpp:56
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36

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

◆ configure() [2/2]

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

◆ execute() [1/2]

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

Implements luci_interpreter::Kernel.

Definition at line 69 of file InstanceNorm.cpp.

70{
71 switch (input()->element_type())
72 {
73 case DataType::FLOAT32:
74 evalFloat();
75 break;
76 default:
77 throw std::runtime_error("luci-intp InstanceNorm Unsupported type.");
78 }
79}

References input().

◆ execute() [2/2]

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

◆ gamma() [1/2]

const Tensor * luci_interpreter::kernels::InstanceNorm::gamma ( ) const
inline

Definition at line 35 of file InstanceNorm.h.

35{ return _inputs[1]; }

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), and InstanceNorm().

◆ gamma() [2/2]

const Tensor * luci_interpreter::kernels::InstanceNorm::gamma ( ) const
inline

Definition at line 35 of file InstanceNorm.h.

35{ return _inputs[1]; }

References luci_interpreter::Kernel::_inputs.

◆ input() [1/2]

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

Definition at line 34 of file InstanceNorm.h.

34{ return _inputs[0]; }

References luci_interpreter::Kernel::_inputs.

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

◆ input() [2/2]

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

Definition at line 34 of file InstanceNorm.h.

34{ return _inputs[0]; }

References luci_interpreter::Kernel::_inputs.

◆ output() [1/2]

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

Definition at line 37 of file InstanceNorm.h.

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

References luci_interpreter::Kernel::_outputs.

Referenced by configure().

◆ output() [2/2]

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

Definition at line 37 of file InstanceNorm.h.

37{ return _outputs[0]; }

References luci_interpreter::Kernel::_outputs.


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