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

#include <SelectV2.h>

Collaboration diagram for luci_interpreter::kernels::SelectV2:

Public Member Functions

 SelectV2 (const Tensor *cond, const Tensor *t, const Tensor *e, Tensor *output)
 
const Tensorcondition () const
 
const Tensort () const
 
const Tensore () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
- 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::Kernel
 Kernel (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs)
 
- 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 SelectV2.h.

Constructor & Destructor Documentation

◆ SelectV2()

luci_interpreter::kernels::SelectV2::SelectV2 ( const Tensor cond,
const Tensor t,
const Tensor e,
Tensor output 
)

Definition at line 32 of file SelectV2.cpp.

33 : Kernel({condition, t, e}, {output})
34{
35}
Kernel(std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs)
Definition Kernel.h:31
const Tensor * condition() const
Definition SelectV2.h:33
const Tensor * t() const
Definition SelectV2.h:34
const Tensor * e() const
Definition SelectV2.h:35

References condition(), e(), and t().

Member Function Documentation

◆ condition()

const Tensor * luci_interpreter::kernels::SelectV2::condition ( ) const
inline

Definition at line 33 of file SelectV2.h.

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

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), and SelectV2().

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 37 of file SelectV2.cpp.

38{
39 LUCI_INTERPRETER_CHECK(condition()->element_type() == DataType::BOOL);
40 LUCI_INTERPRETER_CHECK(t()->element_type() == e()->element_type());
41 LUCI_INTERPRETER_CHECK(t()->element_type() == output()->element_type());
42
43 auto cond_shape = condition()->shape();
44 auto t_shape = t()->shape();
45 auto e_shape = e()->shape();
46
47 output()->resize(
48 calculateShapeForBroadcast(cond_shape, calculateShapeForBroadcast(t_shape, e_shape)));
49}
void resize(const Shape &new_shape)
Definition Tensor.cpp:56
const Shape & shape() const
Definition Tensor.h:107
#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(), condition(), e(), LUCI_INTERPRETER_CHECK, output(), luci_interpreter::Tensor::resize(), luci_interpreter::Tensor::shape(), and t().

◆ e()

const Tensor * luci_interpreter::kernels::SelectV2::e ( ) const
inline

Definition at line 35 of file SelectV2.h.

35{ return _inputs[2]; }

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), and SelectV2().

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 51 of file SelectV2.cpp.

52{
53 auto t_type = t()->element_type();
54 switch (t_type)
55 {
56 case DataType::FLOAT32:
57 evaluate<float>();
58 break;
59 case DataType::S32:
60 evaluate<int32_t>();
61 break;
62 case DataType::S64:
63 evaluate<int64_t>();
64 break;
65 default:
66 throw std::runtime_error("luci-intp SelectV2 unsupported type.");
67 }
68}
DataType element_type() const
Definition Tensor.h:105

References luci_interpreter::Tensor::element_type(), and t().

◆ output()

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

Definition at line 36 of file SelectV2.h.

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

References luci_interpreter::Kernel::_outputs.

Referenced by configure().

◆ t()

const Tensor * luci_interpreter::kernels::SelectV2::t ( ) const
inline

Definition at line 34 of file SelectV2.h.

34{ return _inputs[1]; }

References luci_interpreter::Kernel::_inputs.

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


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