TransData

Availability

Atlas Training Series Product

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.

Example

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);