Compute Library
 21.05
NESlice Class Reference

Basic function to perform tensor slicing. More...

#include <NESlice.h>

Collaboration diagram for NESlice:
[legend]

Public Member Functions

void configure (const ITensorInfo *input, ITensorInfo *output, const Coordinates &starts, const Coordinates &ends)
 Configure kernel. More...
 
- Public Member Functions inherited from INEOperator
 INEOperator (IRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 INEOperator (const INEOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 INEOperator (INEOperator &&)=default
 Default move constructor. More...
 
INEOperatoroperator= (const INEOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INEOperatoroperator= (INEOperator &&)=default
 Default move assignment operator. More...
 
 ~INEOperator ()
 Default destructor. 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 NESlice. More...
 

Detailed Description

Basic function to perform tensor slicing.

Definition at line 38 of file NESlice.h.

Member Function Documentation

◆ configure()

void configure ( 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]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 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 = std::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: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 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: 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 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 NEStridedSliceKernel.
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

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 NEStridedSliceKernel::validate().

Referenced by NESlice::validate().


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