Compute Library
 21.11
CLSlice Class Reference

Basic function to perform tensor slicing. More...

#include <CLSlice.h>

Collaboration diagram for CLSlice:
[legend]

Public Member Functions

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

Detailed Description

Basic function to perform tensor slicing.

Definition at line 38 of file CLSlice.h.

Constructor & Destructor Documentation

◆ CLSlice() [1/3]

CLSlice ( )

Default Constructor.

Definition at line 74 of file CLSlice.cpp.

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

75  : _impl(std::make_unique<Impl>())
76 {
77 }

◆ ~CLSlice()

~CLSlice ( )
default

Default Destructor.

Referenced by CLSlice::CLSlice().

◆ CLSlice() [2/3]

CLSlice ( const CLSlice )
delete

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

◆ CLSlice() [3/3]

CLSlice ( CLSlice &&  )
default

Default move constructor.

Member Function Documentation

◆ configure() [1/2]

void configure ( const ICLTensor input,
ICLTensor output,
const Coordinates starts,
const Coordinates ends 
)

Configure kernel.

Valid data layouts:

  • All

Valid data type configurations:

src dst
All All
Note
Supported tensor rank: up to 4
Start indices must be non-negative. 0 <= starts[i]
End coordinates can be negative, which represents the number of elements before the end of that dimension.
End indices are not inclusive unless negative.
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).

Definition at line 87 of file CLSlice.cpp.

References CLKernelLibrary::get().

Referenced by CLFFTConvolutionLayer::configure(), CLGEMMDeconvolutionLayer::configure(), CLLSTMLayerQuantized::configure(), and arm_compute::test::validation::DATA_TEST_CASE().

88 {
89  configure(CLKernelLibrary::get().get_compile_context(), input, output, starts, ends);
90 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(const ICLTensor *input, ICLTensor *output, const Coordinates &starts, const Coordinates &ends)
Configure kernel.
Definition: CLSlice.cpp:87

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
const ICLTensor input,
ICLTensor output,
const Coordinates starts,
const Coordinates ends 
)

Configure kernel.

Note
Supported tensor rank: up to 4
Start indices must be non-negative. 0 <= starts[i]
End coordinates can be negative, which represents the number of elements before the end of that dimension.
End indices are not inclusive unless negative.
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).

Definition at line 92 of file CLSlice.cpp.

References ITensor::info(), and arm_compute::test::validation::input.

93 {
94  _impl->src = input;
95  _impl->dst = output;
96  _impl->op = std::make_unique<experimental::CLSlice>();
97  _impl->op->configure(compile_context, input->info(), output->info(), starts, ends);
98 }

◆ operator=() [1/2]

CLSlice& operator= ( const CLSlice )
delete

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

Referenced by CLSlice::CLSlice().

◆ operator=() [2/2]

CLSlice & operator= ( CLSlice &&  )
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 100 of file CLSlice.cpp.

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

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), CLFFTConvolutionLayer::run(), CLGEMMDeconvolutionLayer::run(), and CLLSTMLayerQuantized::run().

101 {
102  ITensorPack pack;
103  pack.add_tensor(TensorType::ACL_SRC, _impl->src);
104  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
105  _impl->op->run(pack);
106 }
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,
const Coordinates starts,
const Coordinates ends 
)
static

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

Note
Supported tensor rank: up to 4
Start indices must be non-negative. 0 <= starts[i]
End coordinates can be negative, which represents the number of elements before the end of that dimension.
End indices are not inclusive unless negative.
Parameters
[in]inputSource tensor info. Data type supported: All.
[in]outputDestination tensor info. 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).
Returns
A status

Definition at line 82 of file CLSlice.cpp.

References CLSlice::validate().

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

83 {
84  return experimental::CLSlice::validate(input, output, starts, ends);
85 }
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends)
Static function to check if given info will lead to a valid configuration of CLSlice.
Definition: CLSlice.cpp:50

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