ReFormat

Applicability

Product

Supported

Atlas 350 Accelerator Card

x

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product

Atlas training product

Function Usage

Reformats the input tensor x to the destination format without changing the dimensions and value.

This function unifies the viewFormat, originalFormat, and storageFormat of the input tensor to the specified format.

Prototype

const aclTensor *ReFormat(const aclTensor *x, const op::Format &format, aclOpExecutor *executor=nullptr)

Parameters

Parameter

Input/Output

Description

x

Input

Tensor to be converted. The data type can be FLOAT16, FLOAT32, INT32, UINT32, INT8, or UINT8.

format

Input

Destination format of the input tensor.

executor

Input

Operator executor, containing the operator computation process.

Returns

A tensor in the destination format.

Constraints

The input tensor must have the same dimensions as the data in the specified format.

Examples

1
2
3
// Reformat the input to the NCHW format.
auto reformatInput = l0op::ReFormat(unsqueezedInput, Format::FORMAT_NCHW);
CHECK_RET(reformatInput != nullptr, nullptr);