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

#include <DepthToSpace.h>

Collaboration diagram for luci_interpreter::kernels::DepthToSpace:

Public Member Functions

 DepthToSpace (const Tensor *input, Tensor *output, const DepthToSpaceParams &params)
 
const Tensorinput () const
 
Tensoroutput () const
 
void configure () override
 
void execute () const override
 
- Public Member Functions inherited from luci_interpreter::KernelWithParams< DepthToSpaceParams >
const DepthToSpaceParamsparams () 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< DepthToSpaceParams >
 KernelWithParams (std::vector< const Tensor * > inputs, std::vector< Tensor * > outputs, const DepthToSpaceParams &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< DepthToSpaceParams >
const DepthToSpaceParams _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 DepthToSpace.h.

Constructor & Destructor Documentation

◆ DepthToSpace()

luci_interpreter::kernels::DepthToSpace::DepthToSpace ( const Tensor input,
Tensor output,
const DepthToSpaceParams params 
)

Definition at line 26 of file DepthToSpace.cpp.

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

References input().

Member Function Documentation

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 31 of file DepthToSpace.cpp.

32{
33 LUCI_INTERPRETER_CHECK(input()->shape().num_dims() == 4);
34 LUCI_INTERPRETER_CHECK(output()->element_type() == DataType::FLOAT32 ||
35 output()->element_type() == DataType::U8)
36 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type())
37 const int block_size = params().block_size;
38 const int32_t input_height = input()->shape().dim(1);
39 const int32_t input_width = input()->shape().dim(2);
40 const int32_t input_channels = input()->shape().dim(3);
41 int32_t output_height = input_height * block_size;
42 int32_t output_width = input_width * block_size;
43 int32_t output_channels = input_channels / block_size / block_size;
44
45 LUCI_INTERPRETER_CHECK(input_height == output_height / block_size);
46 LUCI_INTERPRETER_CHECK(input_width == output_width / block_size);
47 LUCI_INTERPRETER_CHECK(input_channels == output_channels * block_size * block_size);
48
50 output_shape.dim(0) = input()->shape().dim(0);
51 output_shape.dim(1) = output_height;
52 output_shape.dim(2) = output_width;
53 output_shape.dim(3) = output_channels;
54
55 output()->resize(output_shape);
56}
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
const luci_interpreter::RuntimeShape output_shape
Definition Shape.h:28

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

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 58 of file DepthToSpace.cpp.

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

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

◆ input()

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

Definition at line 35 of file DepthToSpace.h.

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

References luci_interpreter::Kernel::_inputs.

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

◆ output()

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

Definition at line 36 of file DepthToSpace.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: