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

#include <Mul.h>

Collaboration diagram for luci_interpreter::kernels::Mul:

Public Member Functions

 Mul (const Tensor *input1, const Tensor *input2, Tensor *output, const MulParams &params)
 
const Tensorinput1 () const
 
const Tensorinput2 () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
- Public Member Functions inherited from luci_interpreter::KernelWithParams< MulParams >
const MulParamsparams () 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< MulParams >
 KernelWithParams (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs, const MulParams &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< MulParams >
const MulParams _params
 
- Protected Attributes inherited from luci_interpreter::Kernel
const std::vector< const Tensor * > _inputs
 
const std::vector< Tensor * > _outputs
 

Detailed Description

Definition at line 31 of file Mul.h.

Constructor & Destructor Documentation

◆ Mul()

luci_interpreter::kernels::Mul::Mul ( const Tensor input1,
const Tensor input2,
Tensor output,
const MulParams params 
)

Definition at line 34 of file Mul.cpp.

35 : KernelWithParams<MulParams>({input1, input2}, {output}, params)
36{
37}
Tensor * output() const
Definition Mul.h:38
const Tensor * input1() const
Definition Mul.h:36
const Tensor * input2() const
Definition Mul.h:37

References input1(), and input2().

Member Function Documentation

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 39 of file Mul.cpp.

40{
41 LUCI_INTERPRETER_CHECK(input1()->element_type() == input2()->element_type());
42 LUCI_INTERPRETER_CHECK(output()->element_type() == input1()->element_type());
43 if (input1()->element_type() == DataType::S16)
44 {
45 LUCI_INTERPRETER_CHECK(input1()->zero_points().size() == 1 &&
46 input2()->zero_points().size() == 1)
47 LUCI_INTERPRETER_CHECK(input1()->zero_point() == 0 && input2()->zero_point() == 0 &&
48 output()->zero_point() == 0);
49 }
50
51 output()->resize(calculateShapeForBroadcast(input1()->shape(), input2()->shape()));
52}
#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::Mul::execute ( ) const
overridevirtual

Implements luci_interpreter::Kernel.

Definition at line 54 of file Mul.cpp.

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

References input1().

◆ input1()

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

Definition at line 36 of file Mul.h.

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

References luci_interpreter::Kernel::_inputs.

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

◆ input2()

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

Definition at line 37 of file Mul.h.

37{ return _inputs[1]; }

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), and Mul().

◆ output()

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

Definition at line 38 of file Mul.h.

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