ONE - On-device Neural Engine
Loading...
Searching...
No Matches
arm_compute::CLPadLayerEx Class Reference

#include <CLPadLayerEx.h>

Collaboration diagram for arm_compute::CLPadLayerEx:

Public Member Functions

 CLPadLayerEx ()
 
 CLPadLayerEx (const CLPadLayerEx &)=delete
 
 CLPadLayerEx (CLPadLayerEx &&)=default
 
CLPadLayerExoperator= (const CLPadLayerEx &)=delete
 
CLPadLayerExoperator= (CLPadLayerEx &&)=default
 
void configure (ICLTensor *input, ICLTensor *output, const PaddingList &padding, PixelValue constant_value=PixelValue(), PaddingMode mode=PaddingMode::CONSTANT)
 
void configure (const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, const PaddingList &padding, PixelValue constant_value=PixelValue(), PaddingMode mode=PaddingMode::CONSTANT)
 
void run () override
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, PixelValue constant_value=PixelValue(), PaddingMode mode=PaddingMode::CONSTANT)
 

Detailed Description

Basic function to pad a tensor. This function calls the following OpenCL functions/kernels:

  1. CLPadLayerKernelEx if there is padding to be added
  2. CLCopyKernel otherwise

Definition at line 58 of file CLPadLayerEx.h.

Constructor & Destructor Documentation

◆ CLPadLayerEx() [1/3]

arm_compute::CLPadLayerEx::CLPadLayerEx ( )

Default constructor

Definition at line 45 of file CLPadLayerEx.cpp.

46 : _pad_kernel(std::make_unique<CLPadLayerKernelEx>()), _copy_kernel(std::make_unique<CLCopy>()),
47 _perform_pad(false)
48{
49}

◆ CLPadLayerEx() [2/3]

arm_compute::CLPadLayerEx::CLPadLayerEx ( const CLPadLayerEx )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ CLPadLayerEx() [3/3]

arm_compute::CLPadLayerEx::CLPadLayerEx ( CLPadLayerEx &&  )
default

Default move constructor

Member Function Documentation

◆ configure() [1/2]

void arm_compute::CLPadLayerEx::configure ( const CLCompileContext &  compile_context,
ICLTensor *  input,
ICLTensor *  output,
const PaddingList &  padding,
PixelValue  constant_value = PixelValue(),
PaddingMode  mode = PaddingMode::CONSTANT 
)

Initialize the function

Parameters
[in]compile_contextThe compile context to be used.
[in]inputSource tensor. Data types supported: All.
[out]outputOutput tensor. Data type supported: same as input
[in]paddingThe padding for each spatial dimension of the input tensor. The pair padding[i] specifies the front and the end padding in the i-th dimension.
[in]constant_value(Optional) Constant value to be used for the padding.
[in]mode(Optional) Controls whether the padding should be filled with constant_value using CONSTANT, or reflect the input, either including the border values (SYMMETRIC) or not (REFLECT).

Definition at line 58 of file CLPadLayerEx.cpp.

61{
62 ARM_COMPUTE_ERROR_THROW_ON(
63 validate(input->info(), output->info(), padding, constant_value, mode));
64
65 _perform_pad = std::any_of(padding.begin(), padding.end(),
66 [](PaddingInfo info) { return info.first > 0 || info.second > 0; });
67
68 if (_perform_pad)
69 {
70 _pad_kernel->configure(compile_context, input, output, padding, constant_value, mode);
71 }
72 else
73 {
74 Window copy_window = Window();
75 copy_window.use_tensor_dimensions(output->info()->tensor_shape());
76 // Copy the input to the whole output if no padding is applied
77 _copy_kernel->configure(compile_context, input, output, &copy_window);
78 }
79}
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, PixelValue constant_value=PixelValue(), PaddingMode mode=PaddingMode::CONSTANT)
volatile const char info[]

References info, and validate().

◆ configure() [2/2]

void arm_compute::CLPadLayerEx::configure ( ICLTensor *  input,
ICLTensor *  output,
const PaddingList &  padding,
PixelValue  constant_value = PixelValue(),
PaddingMode  mode = PaddingMode::CONSTANT 
)

Initialize the function

Parameters
[in]inputSource tensor. Data types supported: All.
[out]outputOutput tensor. Data type supported: same as input
[in]paddingThe padding for each spatial dimension of the input tensor. The pair padding[i] specifies the front and the end padding in the i-th dimension.
[in]constant_value(Optional) Constant value to be used for the padding.
[in]mode(Optional) Controls whether the padding should be filled with constant_value using CONSTANT, or reflect the input, either including the border values (SYMMETRIC) or not (REFLECT).

Definition at line 51 of file CLPadLayerEx.cpp.

53{
54 configure(CLKernelLibrary::get().get_compile_context(), input, output, padding, constant_value,
55 mode);
56}
void configure(ICLTensor *input, ICLTensor *output, const PaddingList &padding, PixelValue constant_value=PixelValue(), PaddingMode mode=PaddingMode::CONSTANT)

References configure().

Referenced by configure().

◆ operator=() [1/2]

CLPadLayerEx & arm_compute::CLPadLayerEx::operator= ( CLPadLayerEx &&  )
default

Default move assignment operator

References validate().

◆ operator=() [2/2]

CLPadLayerEx & arm_compute::CLPadLayerEx::operator= ( const CLPadLayerEx )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ run()

void arm_compute::CLPadLayerEx::run ( )
override

Definition at line 99 of file CLPadLayerEx.cpp.

100{
101 if (_perform_pad)
102 {
103 CLScheduler::get().enqueue(*_pad_kernel);
104 }
105 else
106 {
107 _copy_kernel->run();
108 }
109}

Referenced by package.infer.session::inference().

◆ validate()

Status arm_compute::CLPadLayerEx::validate ( const ITensorInfo *  input,
const ITensorInfo *  output,
const PaddingList &  padding,
PixelValue  constant_value = PixelValue(),
PaddingMode  mode = PaddingMode::CONSTANT 
)
static

Static function to check if given info will lead to a valid configuration of CLPadLayerEx.

Parameters
[in]inputSource tensor info. Data types supported: All.
[in]outputOutput tensor info. Data type supported: same as input
[in]paddingThe padding for each spatial dimension of the input tensor. The pair padding[i] specifies the front and the end padding in the i-th dimension.
[in]constant_value(Optional) Constant value to be used for the padding
[in]mode(Optional) Controls whether the padding should be filled with constant_value using CONSTANT, or reflect the input, either including the border values (SYMMETRIC) or not (REFLECT).

Definition at line 80 of file CLPadLayerEx.cpp.

83{
84 bool perform_pad = std::any_of(padding.begin(), padding.end(), [](PaddingInfo info) {
85 return info.first > 0 || info.second > 0;
86 });
87
88 if (perform_pad)
89 {
90 ARM_COMPUTE_RETURN_ON_ERROR(
91 CLPadLayerKernelEx::validate(input, output, padding, constant_value, mode));
92 }
93 else
94 {
95 ARM_COMPUTE_RETURN_ON_ERROR(CLCopy::validate(input, output));
96 }
97 return Status{};
98}
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, PixelValue constant_value=PixelValue(), PaddingMode mode=PaddingMode::CONSTANT)

References info, and arm_compute::CLPadLayerKernelEx::validate().

Referenced by configure(), and operator=().


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