Reshape

Applicability

Product

Supported

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

Function Usage

Reshapes the input tensor x without changing the tensor data.

Prototype

const aclTensor *Reshape(const aclTensor *x, const op::Shape &shape, aclOpExecutor *executor)
const aclTensor *Reshape(const aclTensor *x, const aclIntArray *shape, aclOpExecutor *executor)

Parameters

Parameter

Input/Output

Description

x

Input

Input tensor to be converted. The data type and format are not restricted. The input must be contiguous memory data.

shape

Input

Destination shape. It can be of the aclIntArray* or op::Shape (that is, gert::Shape) type. The data type and format are not restricted.

executor

Input

Operator executor, containing the operator computation process.

Returns

Success: The aclTensor with the destination shape information is returned to the caller. Failure: nullptr is returned.

Constraints

  • The prerequisite for successful reshape is that the shape size of x must be the same as that of shape. For example, if the shape of A is (1, 3, 256, 256), the shape size of A is 1 x 3 x 256 x 256.
  • Currently, this API cannot reshape a tensor into an empty tensor. An empty tensor is a tensor whose shape contains 0.

Examples

1
2
3
4
void Func(const aclTensor *x, const op::Shape &shape, aclOpExecutor *executor) {
    auto ret = l0op::Reshape(x, shape, executor);
    return;
}