Compute Library
 21.02
CLStridedSlice Class Reference

Basic function to run CLStridedSliceKernel. More...

#include <CLStridedSlice.h>

Collaboration diagram for CLStridedSlice:
[legend]

Public Member Functions

 CLStridedSlice (CLRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 ~CLStridedSlice ()
 Destructor. More...
 
 CLStridedSlice (const CLStridedSlice &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLStridedSlice (CLStridedSlice &&)
 Default move constructor. More...
 
CLStridedSliceoperator= (const CLStridedSlice &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLStridedSliceoperator= (CLStridedSlice &&)
 Default move assignment operator. More...
 
void configure (const ICLTensor *input, ICLTensor *output, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, int32_t begin_mask=0, int32_t end_mask=0, int32_t shrink_axis_mask=0)
 Configure kernel. More...
 
void configure (const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, int32_t begin_mask=0, int32_t end_mask=0, int32_t shrink_axis_mask=0)
 Configure kernel. 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, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, int32_t begin_mask=0, int32_t end_mask=0, int32_t shrink_axis_mask=0)
 Static function to check if given info will lead to a valid configuration of CLStridedSlice. More...
 

Detailed Description

Basic function to run CLStridedSliceKernel.

Definition at line 37 of file CLStridedSlice.h.

Constructor & Destructor Documentation

◆ CLStridedSlice() [1/3]

CLStridedSlice ( CLRuntimeContext ctx = nullptr)

Constructor.

Parameters
[in]ctxRuntime context to be used by the function

Definition at line 59 of file CLStridedSlice.cpp.

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

60  : _impl(std::make_unique<Impl>())
61 {
62  _impl->ctx = ctx;
63 }

◆ ~CLStridedSlice()

~CLStridedSlice ( )
default

Destructor.

Referenced by CLStridedSlice::CLStridedSlice().

◆ CLStridedSlice() [2/3]

CLStridedSlice ( const CLStridedSlice )
delete

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

◆ CLStridedSlice() [3/3]

CLStridedSlice ( CLStridedSlice &&  )
default

Default move constructor.

Member Function Documentation

◆ configure() [1/2]

void configure ( const ICLTensor input,
ICLTensor output,
const Coordinates starts,
const Coordinates ends,
const BiStrides strides,
int32_t  begin_mask = 0,
int32_t  end_mask = 0,
int32_t  shrink_axis_mask = 0 
)

Configure kernel.

Note
Supported tensor rank: up to 4
Parameters
[in]inputSource tensor. Data type supported: All.
[out]outputDestination tensor. Data type supported: Same as input
[in]startsThe starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]endsThe ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]stridesThe strides of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]begin_mask(Optional) If the ith bit of begin_mask is set, starts[i] is ignored and the fullest possible range in that dimension is used instead.
[in]end_mask(Optional) If the ith bit of end_mask is set, ends[i] is ignored and the fullest possible range in that dimension is used instead.
[in]shrink_axis_mask(Optional) If the ith bit of shrink_axis_mask is set, it implies that the ith specification shrinks the dimensionality by 1. A slice of size 1 starting from starts[i] in the dimension must be preserved.

Definition at line 69 of file CLStridedSlice.cpp.

References CLKernelLibrary::get().

72 {
73  configure(CLKernelLibrary::get().get_compile_context(), input, output, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask);
74 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(const ICLTensor *input, ICLTensor *output, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, int32_t begin_mask=0, int32_t end_mask=0, int32_t shrink_axis_mask=0)
Configure kernel.

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
const ICLTensor input,
ICLTensor output,
const Coordinates starts,
const Coordinates ends,
const BiStrides strides,
int32_t  begin_mask = 0,
int32_t  end_mask = 0,
int32_t  shrink_axis_mask = 0 
)

Configure kernel.

Note
Supported tensor rank: up to 4
Parameters
[in]compile_contextThe compile context to be used.
[in]inputSource tensor. Data type supported: All.
[out]outputDestination tensor. Data type supported: Same as input
[in]startsThe starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]endsThe ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]stridesThe strides of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]begin_mask(Optional) If the ith bit of begin_mask is set, starts[i] is ignored and the fullest possible range in that dimension is used instead.
[in]end_mask(Optional) If the ith bit of end_mask is set, ends[i] is ignored and the fullest possible range in that dimension is used instead.
[in]shrink_axis_mask(Optional) If the ith bit of shrink_axis_mask is set, it implies that the ith specification shrinks the dimensionality by 1. A slice of size 1 starting from starts[i] in the dimension must be preserved.

Definition at line 76 of file CLStridedSlice.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, and arm_compute::test::validation::input.

79 {
81 
82  _impl->src = input;
83  _impl->dst = output;
84 
85  _impl->op = std::make_unique<experimental::CLStridedSlice>();
86  _impl->op->configure(compile_context, _impl->src->info(), _impl->dst->info(), starts, ends, strides, begin_mask, end_mask, shrink_axis_mask);
87 }
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

◆ operator=() [1/2]

CLStridedSlice& operator= ( const CLStridedSlice )
delete

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

Referenced by CLStridedSlice::CLStridedSlice().

◆ operator=() [2/2]

CLStridedSlice & operator= ( CLStridedSlice &&  )
default

Default move assignment operator.

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For Neon 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 96 of file CLStridedSlice.cpp.

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

97 {
98  ITensorPack pack;
99  pack.add_tensor(TensorType::ACL_SRC, _impl->src);
100  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
101  _impl->op->run(pack);
102 }

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
const Coordinates starts,
const Coordinates ends,
const BiStrides strides,
int32_t  begin_mask = 0,
int32_t  end_mask = 0,
int32_t  shrink_axis_mask = 0 
)
static

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

Note
Supported tensor rank: up to 4
Parameters
[in]inputSource tensor. Data type supported: All.
[in]outputDestination tensor. Data type supported: Same as input
[in]startsThe starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]endsThe ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]stridesThe strides of the dimensions of the input tensor to be sliced. The length must be of rank(input).
[in]begin_mask(Optional) If the ith bit of begin_mask is set, starts[i] is ignored and the fullest possible range in that dimension is used instead.
[in]end_mask(Optional) If the ith bit of end_mask is set, ends[i] is ignored and the fullest possible range in that dimension is used instead.
[in]shrink_axis_mask(Optional) If the ith bit of shrink_axis_mask is set, it implies that the ith specification shrinks the dimensionality by 1. A slice of size 1 starting from starts[i] in the dimension must be preserved.

Definition at line 89 of file CLStridedSlice.cpp.

References CLStridedSlice::validate().

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), and CLUnstack::validate().

92 {
93  return experimental::CLStridedSlice::validate(input, output, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask);
94 }
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, int32_t begin_mask=0, int32_t end_mask=0, int32_t shrink_axis_mask=0)
Static function to check if given info will lead to a valid configuration of CLStridedSlice.

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