Contiguous

Applicable Products

Product

Supported

Ascend 950PR/Ascend 950DT

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Description

Converts a non-contiguous tensor into a contiguous tensor. This function is a public L0 API.

An input tensor of L2 API may be non-contiguous, while an L0 operator supports only a contiguous tensor as the input. Therefore, the tensor needs to be converted into a contiguous tensor before being used as the input of another L0 operator.

An input tensor can be contiguous, which will be processed in the API for better compatibility.

Prototype

const aclTensor *Contiguous(const aclTensor *x, aclOpExecutor *executor)

Parameters

Parameter

Input/Output

Description

x

Input

Input tensor to be converted. The data type and format are not restricted. The input does not have to be contiguous memory, but its expressed data must be within the storage range.

executor

Input

Operator executor, containing the operator computation process.

Return Value

Success: A contiguous aclTensor is returned. Failure: A null pointer is returned.

Constraints

The input tensor must be valid. The shape and stride data must be within the storage range. For example, if shape = (2, 3), stride = (10, 30), storageSize = 8, the actual data exceeds the storage size (8). Therefore, the tensor is invalid, and nullptr is returned by the Contiguous API.

Examples

1
2
3
4
// (Boilerplate) Create an OpExecutor.
auto uniqueExecutor = CREATE_EXECUTOR();
// If self is non-contiguous, conversion is required.
auto selfContiguous = l0op::Contiguous(self, executor);