Slice

Availability

Atlas Training Series Product

Function Usage

Obtains tensor slices.

Prototype

  • const aclTensor *Slice(const aclTensor *x, const aclIntArray *offsets, const aclIntArray *size, aclOpExecutor *executor)
  • const aclTensor *Slice(const aclTensor *x, const aclTensor *y, const aclTensor *offset, const aclTensor *size, aclOpExecutor *executor)

Parameters

Parameter

Input/Output

Description

x

Input

Input tensor. The data type can be FLOAT16, FLOAT, BOOL, INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, or UINT64. The data format can be ND.

y

Output

Output tensor after slicing. The data type can be FLOAT16, FLOAT, BOOL, INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, or UINT64. The data format can be ND.

offsets

Input

const aclIntArray* type, indicating the start position of input x in each dimension slice. The shape is the dimensions of x. The data type can be INT32 or INT64, and the data format can be ND.

offset

Input

const aclTensor* type, indicating the start position of input x in each dimension slice. The shape is the dimensions of x. The data type can be INT32 or INT64, and the data format can be ND.

size

Input

Size of each dimension slice of input x. The shape is the dimensions of x. It can be of the aclIntArray* or aclTensor* type. The data type can be INT32 or INT64, and the data format can be ND.

executor

Input

Operator executor, containing the operator computation process.

Returns

A tensor of the same type as the input tensor and with the shape of size.

Constraints

None

Example

1
2
3
4
// Call l0op::Slice to process each slice.
auto sliceRes = l0op::Slice(self, offsetArray, sizeArray, executor);
// Call l0op::Slice to process each slice.
auto sliceRes = l0op::Slice(xTensor, yTensor, offsetTensor, sizeTensor, executor);