Compute Library
 21.05
CLSlice Class Reference

Basic function to perform tensor slicing. More...

#include <CLSlice.h>

Collaboration diagram for CLSlice:
[legend]

Public Member Functions

void configure (const CLCompileContext &compile_context, const ITensorInfo *input, ITensorInfo *output, const Coordinates &starts, const Coordinates &ends)
 Configure kernel. More...
 
- Public Member Functions inherited from ICLOperator
 ICLOperator (IRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 ICLOperator (const ICLOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ICLOperator (ICLOperator &&)=default
 Default move constructor. More...
 
ICLOperatoroperator= (const ICLOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
ICLOperatoroperator= (ICLOperator &&)=default
 Default move assignment operator. More...
 
void run (ITensorPack &tensors) override
 Run the kernels contained in the function. More...
 
void prepare (ITensorPack &constants) override
 Prepare the function for executing. More...
 
MemoryRequirements workspace () const override
 Return the memory requirements required by the workspace. More...
 
- Public Member Functions inherited from IOperator
virtual ~IOperator ()=default
 Destructor. 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 40 of file CLSlice.h.

Member Function Documentation

◆ configure()

void configure ( const CLCompileContext compile_context,
const ITensorInfo input,
ITensorInfo 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 info. Data type supported: All.
[out]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).

Definition at line 35 of file CLSlice.cpp.

36 {
38 
39  // Get absolute end coordinates
40  const int32_t slice_end_mask = arm_compute::helpers::tensor_transform::construct_slice_end_mask(ends);
41 
42  auto k = std::make_unique<CLStridedSliceKernel>();
43  k->configure(compile_context, input, output, starts, ends, BiStrides(), 0, slice_end_mask, 0);
44  _kernel = std::move(k);
45 }
Coordinates BiStrides
Bidirectional strides.
Definition: Types.h:51
int32_t construct_slice_end_mask(Coordinates ends)
Constructs end mask in case we want to perform a slice operation using the strided slice interface.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

References ARM_COMPUTE_ERROR_ON_NULLPTR, arm_compute::helpers::tensor_transform::construct_slice_end_mask(), and arm_compute::test::validation::input.

◆ 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 47 of file CLSlice.cpp.

48 {
50 
51  // Check start dimensions for being non-negative
52  ARM_COMPUTE_RETURN_ERROR_ON(std::any_of(starts.cbegin(), starts.cbegin() + starts.num_dimensions(), [](int i)
53  {
54  return i < 0;
55  }));
56 
57  // Get absolute end coordinates
58  const int32_t slice_end_mask = arm_compute::helpers::tensor_transform::construct_slice_end_mask(ends);
59 
60  return CLStridedSliceKernel::validate(input, output, starts, ends, BiStrides(), 0, slice_end_mask, 0);
61 }
Coordinates BiStrides
Bidirectional strides.
Definition: Types.h:51
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:296
int32_t construct_slice_end_mask(Coordinates ends)
Constructs end mask in case we want to perform a slice operation using the strided slice interface.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:159
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask)
Static function to check if given info will lead to a valid configuration of CLStridedSliceKernel.

References ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, Dimensions< T >::cbegin(), arm_compute::helpers::tensor_transform::construct_slice_end_mask(), arm_compute::test::validation::input, Dimensions< T >::num_dimensions(), and CLStridedSliceKernel::validate().

Referenced by CLSlice::validate().


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