Reshape

Availability

Atlas Training Series Product

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 (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.

Example

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