Description: The Swin Transformer network model completes the computation of Q, K, and V.
Formula:
q/k/v = (Quant(Layernorm(x).transpose) * weight).dequant.transpose.split Among them,
[object Object]is the concatenation of the weights of the Q, K, and V matrices.
Each operator has calls. First call [object Object] to obtain the required workspace size for computation and the executor that includes the operator's computation process. Then, call [object Object] to perform the computation.
[object Object][object Object]
Parameters:
[object Object](aclTensor*, computation input): Represents the target tensor to be normalized, denoted as[object Object]in the formula. It is an aclTensor on the device side, supporting the FLOAT16 data type. Only supports dimensions [B, S, H], where B is the batch size and only supports [1, 32], S is the product of the original image's length and width, and H is the product of the sequence length and the number of channels, which must be less than or equal to 1024. are not supported. The supports ND.[object Object](aclTensor*, computation input): Represents the scale factor in the layernorm computation, supporting only 1-dimensional size [H]. It is an aclTensor on the device side, with data type supporting FLOAT16. are not supported. The supports ND.[object Object](aclTensor*, computation input): Represents the size of the scale and shift in the layernorm computation. The dimension is only supported as 1D with the shape [H]. It is a device-side aclTensor, and the data type supports FLOAT16. are not supported. The supports ND.[object Object](aclTensor*, computation input): Represents the weight matrix used for the target tensor transformation, which only supports 2 dimensions with the shape [H, 3* H]. It is an aclTensor on the device side, supporting the INT8 data type. are not supported. The supports ND.[object Object](aclTensor*, computation input): Represents the offset matrix used for the target tensor transformation, supporting only 1-dimensional dimensions of [3* H]. The device-side aclTensor supports INT32 data type. are not supported. The supports ND.[object Object](aclTensor*, computation input): Represents the scaling parameter used for quantizing the target tensor. Only 1-dimensional tensors with dimension [H] are supported. The aclTensor on the Device side supports the FLOAT16 data type. are not supported. The supports ND.[object Object](aclTensor*, computation input): Represents the offset parameter used for quantization of the target tensor. Only 1-dimensional tensors with dimension [H] are supported. The aclTensor on the device side supports the FLOAT16 data type. are not supported. The supports ND.[object Object](aclTensor*, computation input): Represents the scaling parameter used for dequantization after the target tensor is multiplied by the weight matrix. Only 1-dimensional tensors with dimensions [3* H] are supported. The aclTensor on the device side supports the UINT64 data type. are not supported. The supports ND.[object Object](int, computation input): Indicates the number of channels used for conversion. Supported range: [1,32].[object Object](int, computation input): Represents the channel depth used for conversion. Only 32/64 are supported.[object Object](float, computation input): The protection value for division by zero in layernorm calculation. To ensure precision, the value less than or equal to 1e-4 is recommended.[object Object](int, computation input): The dimension of the S-axis transpose in layernorm. oriHeight*oriWeight must equal the size of the second dimension S of the input x, and it must be an integer multiple of hWinSize.[object Object](int, computation input): The dimension of the S-axis transpose in layernorm. oriHeight*oriWeight must equal the size of the second dimension S of the input x, and it must be an integer multiple of wWinSize.[object Object](int, computation input): The height size of the feature window used. Supported range: [7,32].[object Object](int, computation input): The width size of the feature window used. Supported range: [7,32].[object Object](bool, computation input): The weight matrix needs to be transposed. The scenario without transposition is currently not supported.[object Object](aclTensor*, computation output): Represents the transformed tensor, denoted as Q in the formula. It is an aclTensor on the device side, supporting the FLOAT16 data type. are not supported. The supports ND.[object Object](aclTensor*, computation output): Represents the transformed tensor, denoted as K in the formula. It is an aclTensor on the device side, supporting the FLOAT16 data type. are not supported. The supports ND.[object Object](aclTensor*, computation output): Represents the transformed tensor, denoted as V in the formula. It is an aclTensor on the device side, supporting the FLOAT16 data type. are not supported. The supports ND.[object Object](uint64_t*, computation output): Returns the size of the workspace that needs to be allocated on the device side.[object Object](aclOpExecutor**, computation output): Returns the op executor, which includes the operator computation process.
Returns:
[object Object]
Parameters:
[object Object](void *, input): The memory address of the workspace allocated on the device side.[object Object](uint64_t, input): The size of the workspace allocated on the device side, obtained by the first-phase API[object Object].[object Object](aclOpExecutor *, input): The op executor, which includes the operator computation process.[object Object](aclrtStream, input): Specifies the stream for task execution.
Returns:
- Deterministic computation:
[object Object]defaults to deterministic implementation.
[object Object]only supports 32/64.- oriHeight * oriWeight = the second dimension of the input x Tensor, and
[object Object]is an integer multiple of[object Object],[object Object]is an integer multiple of[object Object]. - The range of
[object Object]and[object Object]only supports 7-32. - The first dimension B of the input x Tensor only supports values from 1 to 32.
- The weight needs to be transposed.
The following example is for reference only. For details, see .
[object Object]