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

#include <Add.h>

Collaboration diagram for luci_interpreter::kernels::Add:

Public Member Functions

 Add (const Tensor *input1, const Tensor *input2, Tensor *output, const AddParams &params)
 
const Tensorinput1 () const
 
const Tensorinput2 () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
- Public Member Functions inherited from luci_interpreter::KernelWithParams< AddParams >
const AddParamsparams () 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< AddParams >
 KernelWithParams (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs, const AddParams &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< AddParams >
const AddParams _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 Add.h.

Constructor & Destructor Documentation

◆ Add()

luci_interpreter::kernels::Add::Add ( const Tensor input1,
const Tensor input2,
Tensor output,
const AddParams params 
)

Definition at line 33 of file Add.cpp.

34 : KernelWithParams<AddParams>({input1, input2}, {output}, params)
35{
36}
const Tensor * input2() const
Definition Add.h:34
Tensor * output() const
Definition Add.h:35
const Tensor * input1() const
Definition Add.h:33

References input1(), and input2().

Member Function Documentation

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 38 of file Add.cpp.

39{
40 LUCI_INTERPRETER_CHECK(input1()->element_type() == input2()->element_type());
41 LUCI_INTERPRETER_CHECK(input1()->element_type() == output()->element_type());
42 if (input1()->element_type() == DataType::S16)
43 {
44 LUCI_INTERPRETER_CHECK(input1()->zero_points().size() == 1 &&
45 input2()->zero_points().size() == 1);
46 LUCI_INTERPRETER_CHECK(input1()->zero_point() == 0 && input2()->zero_point() == 0 &&
47 output()->zero_point() == 0);
48 }
49
50 output()->resize(calculateShapeForBroadcast(input1()->shape(), input2()->shape()));
51}
void resize(const Shape &new_shape)
Definition Tensor.cpp:56
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
Shape calculateShapeForBroadcast(const Shape &input1_shape, const Shape &input2_shape)
Definition Utils.cpp:204
int32_t size[5]
Definition Slice.cpp:35

References luci_interpreter::kernels::calculateShapeForBroadcast(), input1(), input2(), LUCI_INTERPRETER_CHECK, output(), luci_interpreter::Tensor::resize(), and size.

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 53 of file Add.cpp.

54{
55 switch (input1()->element_type())
56 {
57 case DataType::FLOAT32:
58 evalFloat();
59 break;
60 case DataType::S64:
61 evalInteger<int64_t>();
62 break;
63 case DataType::S32:
64 evalInteger<int32_t>();
65 break;
66 case DataType::U8:
67 evalQuantized();
68 break;
69 case DataType::S16:
70 evalQuantizedS16();
71 break;
72 default:
73 throw std::runtime_error("luci-intp Add Unsupported type.");
74 }
75}

References input1().

◆ input1()

const Tensor * luci_interpreter::kernels::Add::input1 ( ) const
inline

Definition at line 33 of file Add.h.

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

References luci_interpreter::Kernel::_inputs.

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

◆ input2()

const Tensor * luci_interpreter::kernels::Add::input2 ( ) const
inline

Definition at line 34 of file Add.h.

34{ return _inputs[1]; }

References luci_interpreter::Kernel::_inputs.

Referenced by Add(), and configure().

◆ output()

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

Definition at line 35 of file Add.h.

35{ 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: