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

#include <Split.h>

Collaboration diagram for luci_interpreter::kernels::Split:

Public Member Functions

 Split (const Tensor *axis, const Tensor *input, std::vector< Tensor * > outputs)
 
const Tensoraxis () const
 
const Tensorinput () const
 
Tensoroutput (int index) 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 Split.h.

Constructor & Destructor Documentation

◆ Split()

luci_interpreter::kernels::Split::Split ( const Tensor axis,
const Tensor input,
std::vector< Tensor * >  outputs 
)

Definition at line 28 of file Split.cpp.

29 : Kernel({axis, input}, std::move(outputs))
30{
31}
Kernel(std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs)
Definition Kernel.h:31
const Tensor * input() const
Definition Split.h:34
const Tensor * axis() const
Definition Split.h:33

References axis(), and input().

Member Function Documentation

◆ axis()

const Tensor * luci_interpreter::kernels::Split::axis ( ) const
inline

Definition at line 33 of file Split.h.

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

References luci_interpreter::Kernel::_inputs.

Referenced by configure(), and Split().

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 33 of file Split.cpp.

34{
35 assert(axis()->shape().num_elements() == 1);
36 _axis_value = getTensorData<int32_t>(axis())[0];
37 if (_axis_value < 0)
38 _axis_value += input()->shape().num_dims();
39 assert(_axis_value >= 0 && _axis_value < input()->shape().num_dims());
40
41 const int32_t input_size = input()->shape().dim(_axis_value);
42 assert(input_size % _outputs.size() == 0);
43 const int32_t slice_size = input_size / _outputs.size();
44
46 output_shape.dim(_axis_value) = slice_size;
47 for (Tensor *output : _outputs)
48 {
50 }
51}
const std::vector< Tensor * > _outputs
Definition Kernel.h:53
int32_t dim(int i) const
Definition Tensor.h:41
int num_dims() const
Definition Tensor.h:39
void resize(const Shape &new_shape)
Definition Tensor.cpp:56
const Shape & shape() const
Definition Tensor.h:107
Tensor * output(int index) const
Definition Split.h:35
const luci_interpreter::RuntimeShape output_shape
uint32_t num_elements(const Shape &shape)
The number of elements of a feature map of a given shape.
Definition Shape.h:59
Definition Shape.h:28

References luci_interpreter::Kernel::_outputs, axis(), luci_interpreter::Shape::dim(), input(), luci_interpreter::Shape::num_dims(), output(), output_shape, luci_interpreter::Tensor::resize(), and luci_interpreter::Tensor::shape().

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 53 of file Split.cpp.

54{
55 tflite::SplitParams params{};
56 params.num_split = _outputs.size();
57 params.axis = _axis_value;
58
59#define TF_LITE_SPLIT(scalar) \
60 { \
61 VectorOfTensors<scalar, false> all_outputs(_outputs); \
62 luci_interpreter_pal::Split(params, getTensorShape(input()), getTensorData<scalar>(input()), \
63 all_outputs.shapes(), all_outputs.data()); \
64 }
65
66 switch (input()->element_type())
67 {
68 case DataType::FLOAT32:
69 TF_LITE_SPLIT(float);
70 break;
71 case DataType::U8:
72 TF_LITE_SPLIT(uint8_t);
73 break;
74 default:
75 throw std::runtime_error("luci-intp Split Unsupported type.");
76 }
77#undef TF_LITE_SPLIT
78}
#define TF_LITE_SPLIT(scalar)

References luci_interpreter::Kernel::_outputs, input(), and TF_LITE_SPLIT.

◆ input()

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

Definition at line 34 of file Split.h.

34{ return _inputs[1]; }

References luci_interpreter::Kernel::_inputs.

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

◆ output()

Tensor * luci_interpreter::kernels::Split::output ( int  index) const
inline

Definition at line 35 of file Split.h.

35{ return _outputs[index]; }
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

References luci_interpreter::Kernel::_outputs.

Referenced by configure().


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