File: FloatingPointConverter.hpp

package info (click to toggle)
armnn 20.08-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 20,472 kB
  • sloc: cpp: 211,547; python: 2,756; sh: 285; makefile: 38; asm: 6
file content (29 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//
// Copyright © 2019 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#pragma once

#include <cstddef>

namespace armnnUtils
{

class FloatingPointConverter
{
public:
    /// Converts a buffer of FP32 values to FP16, and stores in the given dstFloat16Buffer.
    /// dstFloat16Buffer should be (numElements * 2) in size
    static void ConvertFloat32To16(const float *srcFloat32Buffer, size_t numElements, void *dstFloat16Buffer);

    static void ConvertFloat16To32(const void *srcFloat16Buffer, size_t numElements, float *dstFloat32Buffer);

    // Converts a buffer of FP32 values to BFloat16, and stores in the given dstBFloat16Buffer.
    static void ConvertFloat32ToBFloat16(const float* srcFloat32Buffer, size_t numElements, void* dstBFloat16Buffer);

    // Converts a buffer of BFloat16 to FP32 value, and stores in the given dstFloat32Buffer.
    static void ConvertBFloat16ToFloat32(const void* srcBFloat16Buffer, size_t numElements, float* dstFloat32Buffer);
};

} // namespace armnnUtils