FilesLast commitLast update
9 days ago
4 days ago
10 months ago
4 days ago
3 months ago
4 days ago
4 days ago
4 days ago
27 days ago
4 days ago
4 days ago
README

SignBitsUnpack

English | 简体中文

Product Support Status

Product Supported
Ascend 950PR&950DT products √
Atlas A3 products √
Atlas A2 products √
Atlas 200I/500 A2 inference products √
Atlas inference products √
Atlas training products √

Function Description

  • Operator function: unpacks the 1-bit Adam sign bits of the UINT8 type into a tensor of the FLOAT32 or FLOAT16 type.

  • Computation formula:

Assume that the input self is a 1D UINT8 tensor with the length of N. Each byte contains 8 sign bits in LSB-first order. The unpacking rule for the ii-th bit (from the least significant to the most significant) in the jj-th byte bjb_j (i=0,1,…,7i = 0, 1, \dots, 7) is as follows:

outj⋅8+i={+1.0,biti(bj)=1−1.0,biti(bj)=0out_{j \cdot 8 + i} = \begin{cases} +1.0, & \text{bit}_i(b_j) = 1 \\ -1.0, & \text{bit}_i(b_j) = 0 \end{cases}

The output tensor has N×8N \times 8 elements in total and is reshaped to 2D. Its shape is:

out.shape=(size, N×8size)out.shape = (size,\ \frac{N \times 8}{size})

Here, size is the size of the first dimension of the output specified by the input parameter.

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
self Input Input parameter for the SignBitsUnpack computation. It is a 1D tensor, and each UINT8 element contains 8 sign bits. Empty tensors are supported. UINT8 ND
size Input attribute Indicates dimension processing, which is the first dimension of the output tensor during reshape. INT64 -
dtype Input attribute Indicates the data type of the quantized output tensor. FLOAT16, FLOAT -
out Output Output parameter for the SignBitsUnpack computation. It is a 2D tensor, and its data type is determined by the dtype parameter. FLOAT16, FLOAT ND

Constraint Description

  • self must be a 1-dimensional tensor, and out must be a 2-dimensional tensor.
  • size must be greater than 0, and (the number of elements in self × 8) must be integer-divisible by size.
  • The first dimension of out must be equal to size.
  • The dtype parameter supports only FLOAT16 and FLOAT, and the data type of out must be the same as that specified by the dtype parameter. UINT8 is the data type of self, and INT64 is the API type of size. Neither of them is an optional value of the dtype parameter.
  • Only the ND data format is supported.
  • The empty tensor scenario is supported.
  • Deterministic computation: aclnnSignBitsUnpack defaults to a deterministic implementation.

Invocation Description

Invocation Method Invocation Sample Description
aclnn invocation test_aclnn_sign_bits_unpack Invokes the SignBitsUnpack operator through the aclnnSignBitsUnpack API.
Graph-mode invocation test_geir_sign_bits_unpack Invokes the SignBitsUnpack operator by building a graph through the operator IR.