telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1 | // |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include <cstddef> |
| 9 | |
| 10 | namespace armnnUtils |
| 11 | { |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 12 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 13 | class FloatingPointConverter |
| 14 | { |
| 15 | public: |
Ryan OShea | 2bbfaa7 | 2020-02-12 16:15:27 +0000 | [diff] [blame] | 16 | /// Converts a buffer of FP32 values to FP16, and stores in the given dstFloat16Buffer. |
| 17 | /// dstFloat16Buffer should be (numElements * 2) in size |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 18 | static void ConvertFloat32To16(const float *srcFloat32Buffer, size_t numElements, void *dstFloat16Buffer); |
| 19 | |
| 20 | static void ConvertFloat16To32(const void *srcFloat16Buffer, size_t numElements, float *dstFloat32Buffer); |
Narumol Prangnawarat | 8832522 | 2020-03-06 14:45:57 +0000 | [diff] [blame] | 21 | |
| 22 | // Converts a buffer of FP32 values to BFloat16, and stores in the given dstBFloat16Buffer. |
| 23 | static void ConvertFloat32ToBFloat16(const float* srcFloat32Buffer, size_t numElements, void* dstBFloat16Buffer); |
| 24 | |
| 25 | // Converts a buffer of BFloat16 to FP32 value, and stores in the given dstFloat32Buffer. |
| 26 | static void ConvertBFloat16ToFloat32(const void* srcBFloat16Buffer, size_t numElements, float* dstFloat32Buffer); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 27 | }; |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 28 | |
| 29 | } // namespace armnnUtils |