public class Float16Utils
extends java.lang.Object
Constructor and Description |
---|
Float16Utils() |
Modifier and Type | Method and Description |
---|---|
static java.util.List<java.lang.Float> |
bf16BufferToVector(java.nio.ByteBuffer buf)
Converts a ByteBuffer to bf16 vector upcasts to float32 array.
|
static float |
bf16ToFloat(short input)
Upcasts a bf16 value stored in a short into a float32 value.
|
static java.util.List<java.lang.Short> |
bufferToF16Vector(java.nio.ByteBuffer buf)
Converts a ByteBuffer to a fp16/bf16 vector stored in short array.
|
static java.nio.ByteBuffer |
f16VectorToBuffer(java.util.List<java.lang.Short> vector)
Stores a fp16/bf16 vector into a ByteBuffer.
|
static java.nio.ByteBuffer |
f32VectorToBf16Buffer(java.util.List<java.lang.Float> vector)
Rounds a float32 vector to bf16 values, and stores into a ByteBuffer.
|
static java.nio.ByteBuffer |
f32VectorToFp16Buffer(java.util.List<java.lang.Float> vector)
Rounds a float32 vector to fp16 values, and stores into a ByteBuffer.
|
static short |
floatToBf16(float input)
Converts a float32 into bf16.
|
static short |
floatToFp16(float input)
Rounds a float32 value to a fp16 stored in a short.
|
static java.util.List<java.lang.Float> |
fp16BufferToVector(java.nio.ByteBuffer buf)
Converts a ByteBuffer to fp16 vector upcasts to float32 array.
|
static float |
fp16ToFloat(short input)
Upcasts a fp16 value stored in a short to a float32 value.
|
public static short floatToBf16(float input)
input
- a standard float32 value which will be converted to a bfloat16 valuepublic static float bf16ToFloat(short input)
input
- a bfloat16 value which will be converted to a float32 valuepublic static short floatToFp16(float input)
input
- a standard float32 value which will be converted to a float16 valuepublic static float fp16ToFloat(short input)
input
- a float16 value which will be converted to a float32 valuepublic static java.nio.ByteBuffer f32VectorToBf16Buffer(java.util.List<java.lang.Float> vector)
vector
- a float32 vectorByteBuffer
the vector is converted to bfloat16 values and stored into a ByteBufferpublic static java.util.List<java.lang.Float> fp16BufferToVector(java.nio.ByteBuffer buf)
buf
- a buffer to store a float16 vectorpublic static java.nio.ByteBuffer f32VectorToFp16Buffer(java.util.List<java.lang.Float> vector)
vector
- a float32 vectorByteBuffer
the vector is converted to float16 values and stored in a ByteBufferpublic static java.util.List<java.lang.Float> bf16BufferToVector(java.nio.ByteBuffer buf)
buf
- a buffer to store a bfloat16 vectorpublic static java.nio.ByteBuffer f16VectorToBuffer(java.util.List<java.lang.Short> vector)
vector
- a float16 vector stored in a list of ShortByteBuffer
a buffer to store the float16 vectorpublic static java.util.List<java.lang.Short> bufferToF16Vector(java.nio.ByteBuffer buf)
buf
- a buffer to store a float16 vector