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

#include <SpaceToDepth.h>

Collaboration diagram for luci_interpreter::kernels::SpaceToDepth:

Public Member Functions

 SpaceToDepth (const Tensor *input, Tensor *output, const SpaceToDepthParams &params)
 
const Tensorinput () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
- Public Member Functions inherited from luci_interpreter::KernelWithParams< SpaceToDepthParams >
const SpaceToDepthParamsparams () 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< SpaceToDepthParams >
 KernelWithParams (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs, const SpaceToDepthParams &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< SpaceToDepthParams >
const SpaceToDepthParams _params
 
- Protected Attributes inherited from luci_interpreter::Kernel
const std::vector< const Tensor * > _inputs
 
const std::vector< Tensor * > _outputs
 

Detailed Description

Definition at line 30 of file SpaceToDepth.h.

Constructor & Destructor Documentation

◆ SpaceToDepth()

luci_interpreter::kernels::SpaceToDepth::SpaceToDepth ( const Tensor input,
Tensor output,
const SpaceToDepthParams params 
)

Definition at line 26 of file SpaceToDepth.cpp.

27 : KernelWithParams<SpaceToDepthParams>({input}, {output}, params)
28{
29}
const SpaceToDepthParams & params() const
Definition Kernel.h:67

References input().

Member Function Documentation

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 31 of file SpaceToDepth.cpp.

32{
33 assert(input()->shape().num_dims() == 4);
34 assert(output()->element_type() == DataType::FLOAT32 ||
35 output()->element_type() == DataType::U8 || output()->element_type() == DataType::S8 ||
36 output()->element_type() == DataType::S32 || output()->element_type() == DataType::S64);
37 assert(input()->element_type() == output()->element_type());
38
39 const int block_size = params().block_size;
40 const int32_t input_height = input()->shape().dim(1);
41 const int32_t input_width = input()->shape().dim(2);
42 int32_t output_height = input_height / block_size;
43 int32_t output_width = input_width / block_size;
44
45 assert(input_height == output_height * block_size);
46 assert(input_width == output_width * block_size);
47
49 output_shape.dim(0) = input()->shape().dim(0);
50 output_shape.dim(1) = output_height;
51 output_shape.dim(2) = output_width;
52 output_shape.dim(3) = input()->shape().dim(3) * block_size * block_size;
53
55}
int32_t dim(int i) const
Definition Tensor.h:41
void resize(const Shape &new_shape)
Definition Tensor.cpp:56
const Shape & shape() const
Definition Tensor.h:107
const luci_interpreter::RuntimeShape output_shape
Definition Shape.h:28

References luci_interpreter::SpaceToDepthParams::block_size, luci_interpreter::Shape::dim(), input(), output(), output_shape, luci_interpreter::KernelWithParams< SpaceToDepthParams >::params(), luci_interpreter::Tensor::resize(), and luci_interpreter::Tensor::shape().

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 57 of file SpaceToDepth.cpp.

58{
59 tflite::SpaceToDepthParams op_params{};
60 op_params.block_size = params().block_size;
61 switch (input()->element_type())
62 {
63 case DataType::FLOAT32:
64 luci_interpreter_pal::SpaceToDepth(op_params, getTensorShape(input()),
65 getTensorData<float>(input()), getTensorShape(output()),
66 getTensorData<float>(output()));
67 break;
68 case DataType::U8:
69 luci_interpreter_pal::SpaceToDepth(op_params, getTensorShape(input()),
70 getTensorData<uint8_t>(input()), getTensorShape(output()),
71 getTensorData<uint8_t>(output()));
72 break;
73 default:
74 throw std::runtime_error("luci-intp SpaceToDepth Unsupported type.");
75 }
76}
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
Definition Utils.h:194

References luci_interpreter::SpaceToDepthParams::block_size, luci_interpreter::kernels::getTensorShape(), input(), output(), and luci_interpreter::KernelWithParams< SpaceToDepthParams >::params().

◆ input()

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

Definition at line 35 of file SpaceToDepth.h.

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

References luci_interpreter::Kernel::_inputs.

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

◆ output()

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

Definition at line 36 of file SpaceToDepth.h.

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

References luci_interpreter::Kernel::_outputs.

Referenced by configure(), and execute().


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