Show / Hide Table of Contents

Struct BFloat16

This value type represents A BFloat16 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
System.ValueType.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Namespace: Microsoft.ML.OnnxRuntime.Tensors
Assembly: cs.temp.dll.dll
Syntax
public struct BFloat16

Constructors

BFloat16(UInt16)

Ctor

Declaration
public BFloat16(ushort v)
Parameters
Type Name Description
System.UInt16 v

Fields

value

bfloat16 representation bits

Declaration
public ushort value
Field Value
Type Description
System.UInt16

Methods

Equals(BFloat16)

Returns a value indicating whether this instance and other BFloat16 represent the same value.

Declaration
public bool Equals(BFloat16 other)
Parameters
Type Name Description
BFloat16 other

A BFloat16 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 BFloat16 its value is equal to this instance; otherwise, false.

Overrides
System.ValueType.Equals(System.Object)

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
System.ValueType.GetHashCode()

Operators

Equality(BFloat16, BFloat16)

Compares values of two BFloat16 for binary equality

Declaration
public static bool operator ==(BFloat16 lhs, BFloat16 rhs)
Parameters
Type Name Description
BFloat16 lhs
BFloat16 rhs
Returns
Type Description
System.Boolean

result of value comparisons

Implicit(BFloat16 to UInt16)

Converts to ushort

Declaration
public static implicit operator ushort (BFloat16 bf)
Parameters
Type Name Description
BFloat16 bf

instance of BFloat16

Returns
Type Description
System.UInt16

value member

Implicit(UInt16 to BFloat16)

Converts a 16-bit unsigned integer to a BFloat16.

Declaration
public static implicit operator BFloat16(ushort value)
Parameters
Type Name Description
System.UInt16 value

A 16-bit unsigned integer.

Returns
Type Description
BFloat16

A BFloat16 that represents the converted 16-bit unsigned integer.

Inequality(BFloat16, BFloat16)

Compares values of two BFloat16 for binary inequality

Declaration
public static bool operator !=(BFloat16 lhs, BFloat16 rhs)
Parameters
Type Name Description
BFloat16 lhs
BFloat16 rhs
Returns
Type Description
System.Boolean

result of value comparisons

In This Article
Back to top