FloatDataLayout
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
Bfloat16Layout |
Data layout that converts 32-bit floats from/to 16-bit, truncating their mantissa to 7 bits but
preserving the 8-bit exponent with the same bias. |
Float16Layout |
Data layout that converts 32-bit floats from/to 16-bit, accordingly to the IEEE-754 half-precision
floating point specification. |
|
A DataLayout
that converts data stored in a buffer to floats.
Public Methods
abstract
FloatDataBuffer
|
applyTo(S buffer)
Apply this layout to the provided buffer.
|
abstract
float
|
readFloat(S buffer, long index)
Reads n = scale() values from the buffer at the given index and return them as a float.
|
abstract
Float
|
readObject(S buffer, long index)
Reads n = scale() values from the buffer at the given index and return them as a single
value in the user type.
|
abstract
void
|
writeFloat(S buffer, float value, long index)
Writes a float into the buffer at the given index after converting it to the buffer type.
|
abstract
void
|
|
Inherited Methods
From interface
org.tensorflow.ndarray.buffer.layout.DataLayout
abstract
DataBuffer<Float>
|
applyTo(S buffer)
Apply this layout to the provided buffer.
|
abstract
Float
|
readObject(S buffer, long index)
Reads n = scale() values from the buffer at the given index and return them as a single
value in the user type.
|
abstract
int
|
scale()
Indicates the number of buffer values are required to represent a single user value, default is 1.
|
abstract
void
|
writeObject(S buffer, Float value, long index)
Writes a user value into the buffer at the given index after converting it to the buffer type.
|
Public Methods
public
abstract
FloatDataBuffer
applyTo
(S buffer)
Apply this layout to the provided buffer.
The returned DataBuffer
instance is simply a wrapper to the original buffer and does
not have a backing storage of his own.
Parameters
buffer |
the target buffer to apply this layout to |
Returns
- a buffer with this layout
public
abstract
float
readFloat
(S buffer, long index)
Reads n = scale()
values from the buffer at the given index and return them as a float.
Parameters
buffer |
the buffer to read from |
index |
position of the buffer to read in the buffer |
public
abstract
Float
readObject
(S buffer, long index)
Reads n = scale()
values from the buffer at the given index and return them as a single
value in the user type.
It is the responsibility of the implementors of this interface to read the value to be
converted from the given buffer, using the most appropriate method. For example, for a layout
that converting a single long
to a BigInteger
,
@Override
public BigInteger readObject(LongDataBuffer buffer, long index) {
return BigInteger.valueOf(buffer.getLong(index));
}
If a single user value scales over more than one buffer values,
index
indicates the
starting position of the sequence to be read from the buffer.
Parameters
buffer |
the buffer to read from |
index |
position of the buffer to read in the buffer |
public
abstract
void
writeFloat
(S buffer, float value, long index)
Writes a float into the buffer at the given index after converting it to the buffer type.
Parameters
buffer |
the buffer to write to |
value |
the float to convert and write |
index |
index in the buffer where the converted value should be written |
public
abstract
void
writeObject
(S buffer, Float value, long index)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-11-29 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2021-11-29 UTC."],[],[],null,["# FloatDataLayout\n\npublic interface **FloatDataLayout** \n\n|---|---|---|\n| Known Indirect Subclasses [Bfloat16Layout](/jvm/api_docs/java/org/tensorflow/ndarray/impl/buffer/layout/Bfloat16Layout), [Float16Layout](/jvm/api_docs/java/org/tensorflow/ndarray/impl/buffer/layout/Float16Layout) |-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------| | [Bfloat16Layout](/jvm/api_docs/java/org/tensorflow/ndarray/impl/buffer/layout/Bfloat16Layout) | Data layout that converts 32-bit floats from/to 16-bit, truncating their mantissa to 7 bits but preserving the 8-bit exponent with the same bias. | | [Float16Layout](/jvm/api_docs/java/org/tensorflow/ndarray/impl/buffer/layout/Float16Layout) | Data layout that converts 32-bit floats from/to 16-bit, accordingly to the IEEE-754 half-precision floating point specification. | |||\n\nA [DataLayout](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout) that converts data stored in a buffer to floats. \n\n##### See Also\n\n- [DataLayout](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout) \n\n### Public Methods\n\n|----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [FloatDataBuffer](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/FloatDataBuffer) | [applyTo](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/FloatDataLayout#applyTo(S))(S buffer) Apply this layout to the provided buffer. |\n| abstract float | [readFloat](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/FloatDataLayout#readFloat(S, long))(S buffer, long index) Reads `n = scale()` values from the buffer at the given index and return them as a float. |\n| abstract Float | [readObject](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/FloatDataLayout#readObject(S, long))(S buffer, long index) Reads `n = scale()` values from the buffer at the given index and return them as a single value in the user type. |\n| abstract void | [writeFloat](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/FloatDataLayout#writeFloat(S, float, long))(S buffer, float value, long index) Writes a float into the buffer at the given index after converting it to the buffer type. |\n| abstract void | [writeObject](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/FloatDataLayout#writeObject(S, java.lang.Float, long))(S buffer, Float value, long index) |\n\n### Inherited Methods\n\nFrom interface [org.tensorflow.ndarray.buffer.layout.DataLayout](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout) \n\n|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [DataBuffer](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/DataBuffer)\\\u003cFloat\\\u003e | [applyTo](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout#applyTo(S))(S buffer) Apply this layout to the provided buffer. |\n| abstract Float | [readObject](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout#readObject(S, long))(S buffer, long index) Reads `n = scale()` values from the buffer at the given index and return them as a single value in the user type. |\n| abstract int | [scale](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout#scale())() Indicates the number of buffer values are required to represent a single user value, default is 1. |\n| abstract void | [writeObject](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout#writeObject(S, T, long))(S buffer, Float value, long index) Writes a user value into the buffer at the given index after converting it to the buffer type. |\n\nPublic Methods\n--------------\n\n#### public abstract [FloatDataBuffer](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/FloatDataBuffer)\n**applyTo**\n(S buffer)\n\nApply this layout to the provided buffer.\n\nThe returned [DataBuffer](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/DataBuffer) instance is simply a wrapper to the original buffer and does\nnot have a backing storage of his own.\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| buffer | the target buffer to apply this layout to |\n|--------|-------------------------------------------|\n\n##### Returns\n\n- a buffer with this layout \n\n#### public abstract float\n**readFloat**\n(S buffer, long index)\n\nReads `n = scale()` values from the buffer at the given index and return them as a float. \n\n##### Parameters\n\n| buffer | the buffer to read from |\n| index | position of the buffer to read in the buffer |\n|--------|----------------------------------------------|\n\n##### Returns\n\n- the float value \n\n##### See Also\n\n- [readObject(DataBuffer, long)](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/FloatDataLayout#readObject(S, long)) \n\n#### public abstract Float\n**readObject**\n(S buffer, long index)\n\nReads `n = scale()` values from the buffer at the given index and return them as a single\nvalue in the user type.\n\nIt is the responsibility of the implementors of this interface to read the value to be\nconverted from the given buffer, using the most appropriate method. For example, for a layout\nthat converting a single `long` to a `BigInteger`, \n\n```\n @Override\n public BigInteger readObject(LongDataBuffer buffer, long index) {\n return BigInteger.valueOf(buffer.getLong(index));\n }\n \n```\nIf a single user value scales over more than one buffer values, `index` indicates the starting position of the sequence to be read from the buffer.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| buffer | the buffer to read from |\n| index | position of the buffer to read in the buffer |\n|--------|----------------------------------------------|\n\n##### Returns\n\n- the converted value \n\n#### public abstract void\n**writeFloat**\n(S buffer, float value, long index)\n\nWrites a float into the buffer at the given index after converting it to the buffer type. \n\n##### Parameters\n\n| buffer | the buffer to write to |\n| value | the float to convert and write |\n| index | index in the buffer where the converted value should be written |\n|--------|-----------------------------------------------------------------|\n\n##### See Also\n\n- [writeObject(DataBuffer, Float, long)](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/FloatDataLayout#writeObject(S, java.lang.Float, long)) \n\n#### public abstract void\n**writeObject**\n(S buffer, Float value, long index)\n\n\u003cbr /\u003e"]]