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

#include <ResizeBilinear.h>

Collaboration diagram for luci_interpreter::kernels::ResizeBilinear:

Public Member Functions

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

Constructor & Destructor Documentation

◆ ResizeBilinear()

luci_interpreter::kernels::ResizeBilinear::ResizeBilinear ( const Tensor input,
const Tensor shape,
Tensor output,
const ResizeBilinearParams params 
)

Definition at line 29 of file ResizeBilinear.cpp.

31 : KernelWithParams<ResizeBilinearParams>({input, size}, {output}, params)
32{
33}
const ResizeBilinearParams & params() const
Definition Kernel.h:67

References input(), and size().

Member Function Documentation

◆ configure()

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

Implements luci_interpreter::Kernel.

Definition at line 35 of file ResizeBilinear.cpp.

36{
37 LUCI_INTERPRETER_CHECK(input()->shape().num_dims() == 4);
38 LUCI_INTERPRETER_CHECK(size()->shape().num_dims() == 1);
39 LUCI_INTERPRETER_CHECK(size()->element_type() == DataType::S32);
40 if (params().half_pixel_centers && params().align_corners)
41 throw std::runtime_error("If half_pixel_centers is True, align_corners must be False.");
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::KernelWithParams< ResizeBilinearParams >::params(), luci_interpreter::Tensor::resize(), luci_interpreter::Tensor::shape(), and size().

◆ execute()

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

Implements luci_interpreter::Kernel.

Definition at line 51 of file ResizeBilinear.cpp.

52{
53 tflite::ResizeBilinearParams 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 luci_interpreter_pal::ResizeBilinear(
60 op_params, getTensorShape(input()), getTensorData<float>(input()), getTensorShape(size()),
61 getTensorData<int32_t>(size()), getTensorShape(output()), getTensorData<float>(output()));
62 break;
63 case DataType::U8:
64 luci_interpreter_pal::ResizeBilinear(
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 ResizeBilinear Unsupported type.");
70 }
71}
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
Definition Utils.h:194

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

◆ input()

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

Definition at line 34 of file ResizeBilinear.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 ResizeBilinear().

◆ output()

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

Definition at line 36 of file ResizeBilinear.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::ResizeBilinear::size ( ) const
inline

Definition at line 35 of file ResizeBilinear.h.

35{ return _inputs[1]; }

References luci_interpreter::Kernel::_inputs.

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


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