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

#include <ResizeNearestNeighbor.h>

Collaboration diagram for luci_interpreter::kernels::ResizeNearestNeighbor:

Public Member Functions

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

Constructor & Destructor Documentation

◆ ResizeNearestNeighbor()

luci_interpreter::kernels::ResizeNearestNeighbor::ResizeNearestNeighbor ( const Tensor input,
const Tensor shape,
Tensor output,
const ResizeNearestNeighborParams params 
)

Definition at line 30 of file ResizeNearestNeighbor.cpp.

33 : KernelWithParams<ResizeNearestNeighborParams>({input, size}, {output}, params)
34{
35}
const ResizeNearestNeighborParams & params() const
Definition Kernel.h:67

References input(), and size().

Member Function Documentation

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 37 of file ResizeNearestNeighbor.cpp.

38{
39 LUCI_INTERPRETER_CHECK(input()->shape().num_dims() == 4);
40 LUCI_INTERPRETER_CHECK(size()->shape().num_dims() == 1);
41 LUCI_INTERPRETER_CHECK(size()->element_type() == DataType::S32);
42 LUCI_INTERPRETER_CHECK(size()->shape().dim(0) == 2);
44 output_shape.dim(0) = input()->shape().dim(0);
45 output_shape.dim(1) = getTensorData<int32_t>(size())[0];
46 output_shape.dim(2) = getTensorData<int32_t>(size())[1];
47 output_shape.dim(3) = input()->shape().dim(3);
49}
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
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
const luci_interpreter::RuntimeShape output_shape
Definition Shape.h:28

References luci_interpreter::Shape::dim(), input(), LUCI_INTERPRETER_CHECK, output(), output_shape, luci_interpreter::Tensor::resize(), luci_interpreter::Tensor::shape(), and size().

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 51 of file ResizeNearestNeighbor.cpp.

52{
53 tflite::ResizeNearestNeighborParams op_params{};
54 op_params.align_corners = params().align_corners;
55 op_params.half_pixel_centers = params().half_pixel_centers;
56 switch (output()->element_type())
57 {
58 case DataType::FLOAT32:
59 tflite::reference_ops::ResizeNearestNeighbor(
60 op_params, getTensorShape(input()), getTensorData<int32_t>(input()), getTensorShape(size()),
61 getTensorData<int32_t>(size()), getTensorShape(output()), getTensorData<int32_t>(output()));
62 break;
63 case DataType::U8:
64 luci_interpreter_pal::ResizeNearestNeighbor(
65 op_params, getTensorShape(input()), getTensorData<uint8_t>(input()), getTensorShape(size()),
66 getTensorData<int32_t>(size()), getTensorShape(output()), getTensorData<uint8_t>(output()));
67 break;
68 default:
69 throw std::runtime_error("luci-intp ResizeNearestNeighbor Unsupported type.");
70 }
71}
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
Definition Utils.h:194

References luci_interpreter::ResizeNearestNeighborParams::align_corners, luci_interpreter::kernels::getTensorShape(), luci_interpreter::ResizeNearestNeighborParams::half_pixel_centers, input(), output(), luci_interpreter::KernelWithParams< ResizeNearestNeighborParams >::params(), and size().

◆ input()

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

Definition at line 34 of file ResizeNearestNeighbor.h.

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

References luci_interpreter::Kernel::_inputs.

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

◆ output()

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

Definition at line 36 of file ResizeNearestNeighbor.h.

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

References luci_interpreter::Kernel::_outputs.

Referenced by configure(), and execute().

◆ size()

const Tensor * luci_interpreter::kernels::ResizeNearestNeighbor::size ( ) const
inline

Definition at line 35 of file ResizeNearestNeighbor.h.

35{ return _inputs[1]; }

References luci_interpreter::Kernel::_inputs.

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


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