Struct Float16
This value type represents A Float16 value it is blittable as defined in https://docs.microsoft.com/en-us/dotnet/framework/interop/blittable-and-non-blittable-types and as such, represented the same way in managed and native memories. This means that arrays of this type do not have to be copied to be passed to native memory but simply pinnned and read by native code. Thus, one can create a Tensor on top of an array of these structures and feed it directly to Onnxruntime library. Binary wise, it is the same as ushort[] (uint16_t in C++). However, we would like a separate type for type dispatching.
Inherited Members
Namespace: Microsoft.ML.OnnxRuntime.Tensors
Assembly: cs.temp.dll.dll
Syntax
public struct Float16
Constructors
Float16(UInt16)
Ctor
Declaration
public Float16(ushort v)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt16 | v |
Fields
value
float16 representation bits
Declaration
public ushort value
Field Value
| Type | Description |
|---|---|
| System.UInt16 |
Methods
Equals(Float16)
Returns a value indicating whether this instance and other Float16 represent the same value.
Declaration
public bool Equals(Float16 other)
Parameters
| Type | Name | Description |
|---|---|---|
| Float16 | other | A Float16 object to compare to this instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if other.value is equal to this instance; otherwise, false. |
Equals(Object)
Returns a value indicating whether this instance and a specified System.Object represent the same type and value.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | An System.Object. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if obj is Float16 and its value is equal to this instance; otherwise, false. |
Overrides
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | A 32-bit signed integer hash code. |
Overrides
Operators
Equality(Float16, Float16)
Compares values of two Float16 for binary equality
Declaration
public static bool operator ==(Float16 lhs, Float16 rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Float16 | lhs | |
| Float16 | rhs |
Returns
| Type | Description |
|---|---|
| System.Boolean | result of value comparisons |
Implicit(Float16 to UInt16)
Converts to ushort
Declaration
public static implicit operator ushort (Float16 f)
Parameters
| Type | Name | Description |
|---|---|---|
| Float16 | f | instance of Float16 |
Returns
| Type | Description |
|---|---|
| System.UInt16 | value member |
Implicit(UInt16 to Float16)
Converts a 16-bit unsigned integer to a Float16.
Declaration
public static implicit operator Float16(ushort value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt16 | value | A 16-bit unsigned integer. |
Returns
| Type | Description |
|---|---|
| Float16 | A Float16 that represents the converted 16-bit unsigned integer. |
Inequality(Float16, Float16)
Compares values of two Float16 for binary inequality
Declaration
public static bool operator !=(Float16 lhs, Float16 rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| Float16 | lhs | |
| Float16 | rhs |
Returns
| Type | Description |
|---|---|
| System.Boolean | result of value comparisons |