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

#include <Sub.h>

Collaboration diagram for luci_interpreter::kernels::Sub:

Public Member Functions

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

Constructor & Destructor Documentation

◆ Sub()

luci_interpreter::kernels::Sub::Sub ( const Tensor input1,
const Tensor input2,
Tensor output,
const SubParams params 
)

Definition at line 32 of file Sub.cpp.

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

References input1(), and input2().

Member Function Documentation

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 37 of file Sub.cpp.

38{
39 LUCI_INTERPRETER_CHECK(!(input1()->element_type() != input2()->element_type()))
40 LUCI_INTERPRETER_CHECK(!(input1()->element_type() != output()->element_type()))
41 output()->resize(calculateShapeForBroadcast(input1()->shape(), input2()->shape()));
42}
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
Shape calculateShapeForBroadcast(const Shape &input1_shape, const Shape &input2_shape)
Definition Utils.cpp:204

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

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 44 of file Sub.cpp.

45{
46 switch (input1()->element_type())
47 {
48 case DataType::FLOAT32:
49 evalFloat();
50 break;
51 case DataType::S64:
52 evalInteger<int64_t>();
53 break;
54 case DataType::S32:
55 evalInteger<int32_t>();
56 break;
57 case DataType::U8:
58 evalQuantized();
59 break;
60 default:
61 throw std::runtime_error("luci-intp Sub Unsupported type.");
62 }
63}

References input1().

◆ input1()

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

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

◆ input2()

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

Definition at line 34 of file Sub.h.

34{ return _inputs[1]; }

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), and Sub().

◆ output()

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

Definition at line 35 of file Sub.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: