Compute Library
 21.11
CLCrop Class Reference

Basic function to run opencl::kernels::ClCropKernel. More...

#include <CLCrop.h>

Collaboration diagram for CLCrop:
[legend]

Public Member Functions

 CLCrop ()
 Constructor. More...
 
 ~CLCrop ()
 Destructor. More...
 
 CLCrop (const CLCrop &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLCrop (CLCrop &&)
 Default move constructor. More...
 
CLCropoperator= (const CLCrop &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLCropoperator= (CLCrop &&)
 Default move assignment operator. More...
 
void configure (const ICLTensor *input, ICLTensor *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value=0, Window *output_window=nullptr)
 Configure function. More...
 
void configure (const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value=0, Window *output_window=nullptr)
 Configure function. More...
 
void run () override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 
virtual void prepare ()
 Prepare the function for executing. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value=0, Window *output_window=nullptr)
 Static function to check if given info will lead to a valid configuration of CLStridedSliceKernel. More...
 

Detailed Description

Basic function to run opencl::kernels::ClCropKernel.

Definition at line 39 of file CLCrop.h.

Constructor & Destructor Documentation

◆ CLCrop() [1/3]

CLCrop ( )

Constructor.

Definition at line 46 of file CLCrop.cpp.

References CLCrop::operator=(), and CLCrop::~CLCrop().

47  : _impl(std::make_unique<Impl>())
48 {
49 }

◆ ~CLCrop()

~CLCrop ( )
default

Destructor.

Referenced by CLCrop::CLCrop().

◆ CLCrop() [2/3]

CLCrop ( const CLCrop )
delete

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

◆ CLCrop() [3/3]

CLCrop ( CLCrop &&  )
default

Default move constructor.

Member Function Documentation

◆ configure() [1/2]

void configure ( const ICLTensor input,
ICLTensor output,
Coordinates2D  start,
Coordinates2D  end,
uint32_t  batch_index,
float  extrapolation_value = 0,
Window output_window = nullptr 
)

Configure function.

Note
Supported tensor rank: up to 4

Valid data layouts:

  • NHWC

Valid data type configurations:

src dst
All F32
Parameters
[in]inputSource tensor. Data type supported: All. Data layouts supported: NHWC.
[out]outputDestination tensor. Data type supported: F32
[in]startCoordinates of where to start cropping the image.
[in]endCoordinates of where to end cropping the image.
[in]batch_indexFourth dimension index of the 3D image to crop in input.
[in]extrapolation_valueValue to be used for values outside of the image. Default is 0.
[in]output_windowOutput window to be used in case cropped image is being copied into a tensor. Default is nullptr.

Definition at line 54 of file CLCrop.cpp.

References CLKernelLibrary::get().

56 {
57  configure(CLKernelLibrary::get().get_compile_context(), src, dst, start, end, batch_index, extrapolation_value, dst_window);
58 }
void configure(const ICLTensor *input, ICLTensor *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value=0, Window *output_window=nullptr)
Configure function.
Definition: CLCrop.cpp:54
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
SimpleTensor< float > src
Definition: DFT.cpp:155

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
const ICLTensor input,
ICLTensor output,
Coordinates2D  start,
Coordinates2D  end,
uint32_t  batch_index,
float  extrapolation_value = 0,
Window output_window = nullptr 
)

Configure function.

Note
Supported tensor rank: up to 4
Parameters
[in]compile_contextThe compile context to be used.
[in]inputSource tensor. Data type supported: All. Data layouts supported: NHWC.
[out]outputDestination tensor. Data type supported: F32
[in]startCoordinates of where to start cropping the image.
[in]endCoordinates of where to end cropping the image.
[in]batch_indexFourth dimension index of the 3D image to crop in input.
[in]extrapolation_valueValue to be used for values outside of the image. Default is 0.
[in]output_windowOutput window to be used in case cropped image is being copied into a tensor. Default is nullptr.

Definition at line 60 of file CLCrop.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_LOG_PARAMS, arm_compute::test::validation::dst, arm_compute::mlgo::parser::end(), and arm_compute::test::validation::src.

62 {
64  ARM_COMPUTE_LOG_PARAMS(src, dst, start, end, batch_index, extrapolation_value, dst_window);
65 
66  _impl->src = src;
67  _impl->dst = dst;
68 
69  _impl->op = std::make_unique<opencl::ClCrop>();
70  _impl->op->configure(compile_context, _impl->src->info(), _impl->dst->info(), start, end, batch_index, extrapolation_value, dst_window);
71 }
SimpleTensor< float > src
Definition: DFT.cpp:155
void end(TokenStream &in, bool &valid)
Definition: MLGOParser.cpp:290
#define ARM_COMPUTE_LOG_PARAMS(...)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ operator=() [1/2]

CLCrop& operator= ( const CLCrop )
delete

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

Referenced by CLCrop::CLCrop().

◆ operator=() [2/2]

CLCrop & operator= ( CLCrop &&  )
default

Default move assignment operator.

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For CPU kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
Note
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
Note
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 78 of file CLCrop.cpp.

References arm_compute::ACL_DST, arm_compute::ACL_SRC, ITensorPack::add_tensor(), and arm_compute::test::validation::pack.

79 {
80  ITensorPack pack;
81  pack.add_tensor(TensorType::ACL_SRC, _impl->src);
82  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
83  _impl->op->run(pack);
84 }
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
Definition: ITensorPack.cpp:39

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
Coordinates2D  start,
Coordinates2D  end,
uint32_t  batch_index,
float  extrapolation_value = 0,
Window output_window = nullptr 
)
static

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

Note
Supported tensor rank: up to 4
Parameters
[in]inputSource tensor info. Data type supported: All. Data layouts supported: NHWC.
[in]outputDestination tensor info. Data type supported: F32
[in]startCoordinates of where to start cropping the image.
[in]endCoordinates of where to end cropping the image.
[in]batch_indexFourth dimension index of the 3D image to crop in input.
[in]extrapolation_valueValue to be used for values outside of the image. Default is 0.
[in]output_windowOutput window to be used in case cropped image is being copied into a tensor. Default is nullptr.

Definition at line 73 of file CLCrop.cpp.

References ClCrop::validate().

Referenced by CLCropResize::validate().

74 {
75  return opencl::ClCrop::validate(input, output, start, end, batch_index, extrapolation_value, dst_window);
76 }
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value=0, Window *dst_window=nullptr)
Static function to check if given info will lead to a valid configuration.
Definition: ClCrop.cpp:44

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