TransData

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

x

Atlas inference products

Atlas training products

Function Usage

Converts the tensor's format without changing its value.

Specifically, this API converts the format of an input tensor into the specified dstPrimaryFormat.

Prototype

const aclTensor *TransData(const aclTensor *x, op::Format dstPrimaryFormat, int64_t groups, aclOpExecutor *executor)

Parameters

Parameter

Input/Output

Description

x

Input

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

dstPrimaryFormat

Input

Destination format of the input tensor.

groups

Input

Group parameter, which is used for conversion by group. The data type can be INT64.

executor

Input

Operator executor, containing the operator computation process.

Returns

A tensor of dstPrimaryFormat.

Constraints

When the input tensor is of type FLOAT32, INT32, or UINT32, C0 can only be processed based on 8.

Examples

1
2
3
// Convert the output format from NC1HWC0 to NCHW.
auto transGradInput = l0op::TransData(gradInputNC1HWC0, Format::FORMAT_NCHW, params.groups, executor);
CHECK_RET(transGradInput != nullptr, ACLNN_ERR_INNER_NULLPTR);