# Tensor

- typedef struct [FadasTensorFormat](https://docs.qualcomm.com/doc/80-63309-1/topic/struct_fadas_tensor_format.html#_CPPv417FadasTensorFormat) FadasTensorFormat\_t

    - Tensor format structure.

- Param n:

    - Number of batches in the tensor.

- Param w:

    - Width of the tensor.

- Param h:

    - Height of the tensor.

- Param c:

    - Number of channels in the tensor.

- Param n\_stride:

    - Stride for the batch dimension.

- Param w\_stride:

    - Stride for the width dimension.

- Param h\_stride:

    - Stride for the height dimension.

- Param c\_stride:

    - Stride for the channel dimension.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_Init(const char \*licenseKey)

    - Initialize the tensor feature. **WARNING:** Must be called once before other FastADAS functions. except [FadasVersion()](https://docs.qualcomm.com/doc/80-63309-1/topic/misc.html#group__misc_1ga55cbdff48d751f2a0227ae4ac106d746).

- Parameters:

    - **licenseKey** – License key string.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_DeInit(void)

    - Deinitialize the tensor feature. **WARNING:** This function must be called once after all other FastADAS functions.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_Dot2Dx(uint32\_t n, uint32\_t nY, uint32\_t nX, const [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict A, uint32\_t strideA, const [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict B, uint32\_t strideB, [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict c, uint32\_t strideC)

    - Dot product of N 2D matrices (rank 2 tensors) into N 1D column vectors (rank 1 tensors) and output the result into separate memory. Equivalent to multiple calls in MATLAB of dot(A, B, 2).

- Parameters:

    - - **n** – Number of A and B matrices, as well as output vectors.
- **nY** – Number of rows in both A and B.
- **nX** – Number of columns in both A and B.
- **A** – Pointer to nX by nY matrix. **WARNING:** Must be 128-byte aligned.
- **strideA** – Input matrix stride. The gap (in bytes) between the first element of a matrix and the gap of the successive matrix. **WARNING:** Must be a multiple of 4.
- **B** – Pointer to nX by nY matrix. **WARNING:** Must be 128-byte aligned.
- **strideB** – Input matrix stride. The gap (in bytes) between the first element of a matrix and the gap of the successive matrix. **WARNING:** Must be a multiple of 4.
- **c** – Output vectors of size nY. **WARNING:** Must be 128-byte aligned.
- **strideC** – Output vector stride. The gap (in bytes) between the first element of a vector and the gap of the successive vector. **WARNING:** Must be a multiple of 4.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_Dot2Dy(uint32\_t n, uint32\_t nY, uint32\_t nX, const [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict A, uint32\_t strideA, const [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict B, uint32\_t strideB, [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict c, uint32\_t strideC)

    - Dot product of two 2D matrices (rank 2 tensors) with a multiple 1D column vectors (rank 1 tensors) and outputs the result into separate memory. Equivalent to multiple calls in MATLAB of dot(A, B, 1).

- Parameters:

    - - **n** – Number of A and B matrices, as well as output vectors.
- **nY** – Number of rows in both A and B.
- **nX** – Number of columns in both A and B.
- **A** – Pointer to nX by nY matrix. **WARNING:** Must be 128-byte aligned.
- **strideA** – Input matrix stride. The gap (in bytes) between the first element of a matrix and that of the next successive matrix. **WARNING:** Must be a multiple of 4.
- **B** – Pointer to nX by nY matrix. **WARNING:** Must be 128-byte aligned.
- **strideB** – Input matrix stride. The gap (in bytes) between the first element of a matrix and that of the next successive matrix. **WARNING:** Must be a multiple of 4.
- **c** – Output vectors of size nX. **WARNING:** Must be 128-byte aligned.
- **strideC** – Output vector stride. The gap (in bytes) between the first element of a vector and that of the next successive vector. **WARNING:** Must be a multiple of 4.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_Multiply3x3byNx3(const [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict M, uint32\_t strideM, uint32\_t nPts, const [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict src, uint32\_t srcStride, [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict dst, uint32\_t dstStride)

    - Multiplies a 2D 3 x 3 matrix (rank 2 tensor) with multiple 1D column vectors (rank 1 tensors) and outputs the result into separate memory.

- Parameters:

    - - **M** – Pointer to a 3 x 3 matrix.
- **strideM** – Input matrix stride (in bytes), the gap between the first element of a row and that of the successive row. If the value is equal to 0, a value is calculated assuming contiguous memory.
- **nPts** – Number of points to follow in both input and output.
- **src** – Pointer to the input points represented by an array of 1 x 3 floating-point vectors. **WARNING:** Must be 128-byte aligned.
- **srcStride** – Input points stride, gap (in terms of bytes) between the first element of a 1 x 3 vector and the first element of the successive 1 x 3 vector. If the value is equal to 0, a value is calculated assuming contiguous memory. **WARNING:**

    - Must be a multiple of 8.
    - Must be 128-byte aligned.
- **dst** – Pointer to the output image that has the same type, and size as the input image. The size of buffer is dstStride\*n\_pts bytes. **WARNING:** Must be 128-byte aligned.
- **dstStride** – Output points stride, the gap (in terms of bytes) between the first element of a 1 x 3 vector and the first element of the successive 1 x 3 vector. If the value is equal to 0, a value is calculated assuming contiguous memory. **WARNING:**

    - Must be a multiple of 8.
    - Must be 128-byte aligned.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_Multiply4x4byNx4(const [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict M, uint32\_t strideM, uint32\_t nPts, const [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict src, uint32\_t srcStride, [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict dst, uint32\_t dstStride)

    - Multiplies a 2D 4 x 4 matrix (rank 2 tensor) with a multiple 1D column vectors (rank 1 tensors) and outputs the result into separate memory.

- Parameters:

    - - **M** – Pointer to 4 x 4 matrix.
- **strideM** – Input matrix stride (in bytes), the gap between the first element of a row and that of the successive row. If the value is equal to 0, a value is calculated assuming contiguous memory.
- **nPts** – Number of points to follow in both input and output.
- **src** – Input points represented by an array of 1 x 4 floating-point vectors. **WARNING:** Must be 128-byte aligned.
- **srcStride** – Input points stride, the gap (in terms of bytes) between the first element of a 1 x 4 vector and the first element of the successive 1 x 4 vector. If the value is equal to 0, a value is calculated assuming contiguous memory. **WARNING:**

    - Must be a multiple of 8
    - Must be 128-byte aligned.
- **dst** – Output image with the same type, and size as the input image. The size of buffer is dstStride\*nPts bytes. **WARNING:** Must be 128-byte aligned.
- **dstStride** – Output points stride, the gap (in terms of bytes) between the first element of a 1 x 4 vector and the first element of the successive 1 x 4 vector. If the value is equal to 0, a value is calculated assuming contiguous memory. **WARNING:**

    - Must be a multiple of 8
    - Must be 128-byte aligned.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_MatrixMultiply(uint32\_t n, [FadasMatrix\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/struct_fadas_matrix__t.html#_CPPv413FadasMatrix_t) \*src1, [FadasMatrix\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/struct_fadas_matrix__t.html#_CPPv413FadasMatrix_t) \*src2, [FadasMatrix\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/struct_fadas_matrix__t.html#_CPPv413FadasMatrix_t) \*dst)

    - Multiplies multiple 2D matrices and stores the output matrices in separate memory.

- Parameters:

    - - **n** – Number of matrices to multiply.
- **src1** – Pointer to the input matrix structure that describes dimensions and stride between two rows of the matrix in bytes. The structure also stores the memory where source matrix or matrices are stored.
- **src2** – Pointer to the input matrix structure that describes dimensions and stride between two rows of the matrix in bytes. The structure also stores the memory where source matrix or matrices are stored.
- **dst** – Pointer to the destination matrix structure that stores the result matrix or matrices dimensions, stride in bytes between matrix rows. The structure also stores the memory address where the result is stored.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_NCHW2NHWCf32(const [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict srcA, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtA, [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict dstB, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtB)

    - Converts a tensor from NCHW to NHWC format.

- Parameters:

    - - **srcA** – Pointer to the source tensor in float32 format. **WARNING:** Must be 128-byte aligned.
- **fmtA** – Pointer to the format descriptor for the source tensor.
- **dstB** – Pointer to the destination tensor in float32 format. **WARNING:** Must be 128-byte aligned.
- **fmtB** – Pointer to the format descriptor for the destination tensor.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_NHWC2NCHWf32(const [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict srcA, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtA, [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict dstB, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtB)

    - Converts a tensor from NHWC to NCHW format.

- Parameters:

    - - **srcA** – Pointer to the source tensor in float32 format. **WARNING:** Must be 128-byte aligned.
- **fmtA** – Pointer to the format descriptor for source tensor.
- **dstB** – Pointer to the destination tensor in float32 format. **WARNING:** Must be 128-byte aligned.
- **fmtB** – Pointer to the format descriptor for destination tensor B.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_NCHW2NHWCi8(const int8\_t \*\_\_restrict srcA, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtA, int8\_t \*\_\_restrict dstB, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtB)

    - Converts a tensor from NCHW to NHWC format.

- Parameters:

    - - **srcA** – Pointer to the source tensor in int8 format. **WARNING:** Must be 128-byte aligned.
- **fmtA** – Pointer to the format descriptor for source tensor.
- **dstB** – Pointer to the destination tensor in int8 format. **WARNING:** Must be 128-byte aligned.
- **fmtB** – Pointer to the format descriptor for destination tensor.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_NHWC2NCHWi8(const int8\_t \*\_\_restrict srcA, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtA, int8\_t \*\_\_restrict dstB, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtB)

    - Converts a tensor from NHWC to NCHW format.

- Parameters:

    - - **srcA** – Pointer to the source tensor in int8 format. **WARNING:** Must be 128-byte aligned.
- **fmtA** – Pointer to the format descriptor for source tensor.
- **dstB** – Pointer to the destination tensor in int8 format. **WARNING:** Must be 128-byte aligned.
- **fmtB** – Pointer to the format descriptor for destination tensor.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_NCHW2NHWCu8(const uint8\_t \*\_\_restrict srcA, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtA, uint8\_t \*\_\_restrict dstB, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtB)

    - Converts a tensor from NCHW to NHWC format.

- Parameters:

    - - **srcA** – Pointer to the source tensor in uint8 format. **WARNING:** Must be 128-byte aligned.
- **fmtA** – Pointer to the format descriptor for source tensor.
- **dstB** – Pointer to the destination tensor in uint8 format. **WARNING:** Must be 128-byte aligned.
- **fmtB** – Pointer to the format descriptor for destination tensor.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_NHWC2NCHWu8(const uint8\_t \*\_\_restrict srcA, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtA, uint8\_t \*\_\_restrict dstB, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtB)

    - Converts a tensor from NHWC to NCHW format.

- Parameters:

    - - **srcA** – Pointer to the source tensor in uint8 format. **WARNING:** Must be 128-byte aligned.
- **fmtA** – Pointer to the format descriptor for source tensor.
- **dstB** – Pointer to the destination tensor in uint8 format. **WARNING:** Must be 128-byte aligned.
- **fmtB** – Pointer to the format descriptor for destination tensor.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_RenormalizeNHWCu8f32(const uint8\_t \*\_\_restrict srcA, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtA, [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict dstB, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtB, [FadasNormlzParams\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/struct_fadas_normlz_params__t.html#_CPPv419FadasNormlzParams_t) normlz)

    - Four-dimensional version of [FadasCvtYUV\_Renormalize()](https://docs.qualcomm.com/doc/80-63309-1/topic/image-conversion-functions.html#group__cvtyuvh_1ga32aa56a645732302e733b63b9734c645). Scales a tensor \((A)\) of 8-bit NHWC values \((A\_{ijkl})\) to create a 32-bit floating point tensor \((B)\) by subtracting a constant \((s)\), multiplying by another constant \((m)\), and then adding by another constant \((a)\).

\[ B\_{ijkl} = m (A\_{ijkl} - s) + a \]

When dealing with the output of a quantized network running on fixed-point hardware or software, this routine can reverse that quantization by using a zero as the addition value \((a=0)\).

Global batch normalization using a global mean \((s = \mu)\) and standard deviation \((m = 1/\sigma)\) along with no addition \((a=0)\).

\[ B\_{ijkl} = (A\_{ijkl} - \mu)/\sigma \]

 Scaling to a new mean \((\mu')\) and width \((\sigma')\) can be combined into single constants \(m = \sigma'/\sigma\), \(s = \mu\), and \(a = \mu'\). 
\[\begin{split}\begin{eqnarray\*} B\_{ijkl} &=& m (A\_{ijkl} - s) + a \\ &=& (\sigma'/\sigma)(A\_{ijkl} - \mu) + \mu' \end{eqnarray\*}\end{split}\]

- Parameters:

    - - **srcA** – Pointer to the source tensor. **WARNING:** Must be 128-byte aligned.
- **fmtA** – Pointer to the format descriptor for source tensor.
- **dstB** – Pointer to the destination tensor. **WARNING:** Must be 128-byte aligned.
- **fmtB** – Pointer to the format descriptor for destination tensor. **WARNING:** Last dimension (C) must stride of 4 [*i.e*., sizeof(float32\_t)].
- **normlz** – Normalization parameters apply to all color channels equally.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- [FadasError\_e](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#_CPPv412FadasError_e) FadasTensor\_RenormalizeNCHWu8f32(const uint8\_t \*\_\_restrict srcA, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtA, [float32\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_fadas_8h_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict dstB, [FadasTensorFormat\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/typedef_group__tensor_1ga7fa725fdc0183d72c5c8de2b07fc6ff6.html#_CPPv419FadasTensorFormat_t) \*fmtB, [FadasNormlzParams\_t](https://docs.qualcomm.com/doc/80-63309-1/topic/struct_fadas_normlz_params__t.html#_CPPv419FadasNormlzParams_t) normlz)

    - Similar to a four-dimensional version of [FadasCvtYUV\_Renormalize()](https://docs.qualcomm.com/doc/80-63309-1/topic/image-conversion-functions.html#group__cvtyuvh_1ga32aa56a645732302e733b63b9734c645). Scales a tensor \((A)\) of 8-bit NCHW values \((A\_{ijkl})\) to create a 32-bit floating point tensor \((B)\) by subtracting a constant \((s)\), then multiplying by another constant \((m)\), and then adding by another constant \((a)\) thereafter.

\[ B\_{ijkl} = m (A\_{ijkl} - s) + a \]

When dealing with the output of a quantized network running on fixed-point hardware or software, this routine can reverse that quantization by using a zero as the addition value \((a=0)\).

Global batch normalization using a global mean \((s = \mu)\) and standard deviation \((m = 1/\sigma)\) along with no addition \((a=0)\).

\[ B\_{ijkl} = (A\_{ijkl} - \mu)/\sigma \]

 Scaling to a new mean \((\mu')\) and width \((\sigma')\) can be combined into single constants \(m = \sigma'/\sigma\), \(s = \mu\), and \(a = \mu'\). 
\[\begin{split}\begin{eqnarray\*} B\_{ijkl} &=& m (A\_{ijkl} - s) + a \\ &=& (\sigma'/\sigma)(A\_{ijkl} - \mu) + \mu' \end{eqnarray\*}\end{split}\]

- Parameters:

    - - **srcA** – Pointer to the source tensor. **WARNING:** Must be 128-byte aligned.
- **fmtA** – Pointer to the format descriptor for source tensor.
- **dstB** – Pointer to the destination tensor. **WARNING:** Must be 128-byte aligned.
- **fmtB** – Pointer to the format descriptor for destination tensor. **WARNING:** Last dimension (W) must stride of 4 [sizeof(float32\_t)].
- **normlz** – Normalization parameters apply to all color channels equally.

- Returns:

    - [FADAS\_ERROR\_NONE](https://docs.qualcomm.com/doc/80-63309-1/topic/enum_fadas_8h_1a280abf443019bfc722ac1158e5fe1013.html#fadas_8h_1a280abf443019bfc722ac1158e5fe1013aea09a4171f0866f38326d7e5323f2d12) — Success.

- struct FadasTensorFormat

    - Tensor format structure.

- Param n:

    - Number of batches in the tensor.

- Param w:

    - Width of the tensor.

- Param h:

    - Height of the tensor.

- Param c:

    - Number of channels in the tensor.

- Param n\_stride:

    - Stride for the batch dimension.

- Param w\_stride:

    - Stride for the width dimension.

- Param h\_stride:

    - Stride for the height dimension.

- Param c\_stride:

    - Stride for the channel dimension.

Public Members

- uint32\_t n

    - 

- uint32\_t w

    - 

- uint32\_t h

    - 

- uint32\_t c

    - 

- uint32\_t n\_stride

    - 

- uint32\_t w\_stride

    - 

- uint32\_t h\_stride

    - 

- uint32\_t c\_stride

    -

## Related examples

- [one/one.cpp](https://docs.qualcomm.com/doc/80-63309-1/topic/one.html)

Last Published: Sep 30, 2024

[Previous Topic
Matrix Decomposition](https://docs.qualcomm.com/bundle/publicresource/80-63309-1/topics/matrix-decomposition.md) [Next Topic
Transform](https://docs.qualcomm.com/bundle/publicresource/80-63309-1/topics/transform.md)