Compute Library
 19.08
NESlice Class Reference

Basic function to perform tensor slicing. More...

#include <NESlice.h>

Collaboration diagram for NESlice:
[legend]

Public Member Functions

void configure (const ITensor *input, ITensor *output, const Coordinates &starts, const Coordinates &ends)
 Configure kernel. More...
 
- Public Member Functions inherited from INESimpleFunctionNoBorder
 INESimpleFunctionNoBorder ()
 Constructor. More...
 
void run () override final
 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 NESlice. More...
 

Detailed Description

Basic function to perform tensor slicing.

Definition at line 35 of file NESlice.h.

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor 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]inputSource tensor. Data type supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32
[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 36 of file NESlice.cpp.

37 {
39 
40  // Get absolute end coordinates
41  const int32_t slice_end_mask = arm_compute::helpers::tensor_transform::construct_slice_end_mask(ends);
42 
43  auto k = arm_compute::support::cpp14::make_unique<NEStridedSliceKernel>();
44  k->configure(input, output, starts, ends, BiStrides(), 0, slice_end_mask, 0);
45  _kernel = std::move(k);
46 }
Coordinates BiStrides
Bidirectional strides.
Definition: Types.h:49
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:161

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

Referenced by NEFFTConvolutionLayer::configure(), and NELSTMLayerQuantized::configure().

◆ 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 NESlice.

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: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32
[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 48 of file NESlice.cpp.

49 {
51 
52  // Check start dimensions for being non-negative
53  ARM_COMPUTE_RETURN_ERROR_ON(std::any_of(starts.cbegin(), starts.cbegin() + starts.num_dimensions(), [](int i)
54  {
55  return i < 0;
56  }));
57 
58  // Get absolute end coordinates
59  const int32_t slice_end_mask = arm_compute::helpers::tensor_transform::construct_slice_end_mask(ends);
60 
61  return NEStridedSliceKernel::validate(input, output, starts, ends, BiStrides(), 0, slice_end_mask, 0);
62 }
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.
Coordinates BiStrides
Bidirectional strides.
Definition: Types.h:49
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:244
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:163

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

Referenced by NESplit::validate(), and NELSTMLayerQuantized::validate().


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