TensorSpan<T> Struct
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a contiguous region of arbitrary memory. Unlike arrays, it can point to either managed or native memory, or to memory allocated on the stack. It is type-safe and memory-safe.
generic <typename T>
public value class TensorSpan
public readonly ref struct TensorSpan<T>
type TensorSpan<'T> = struct
Public Structure TensorSpan(Of T)
Type Parameters
- T
- Inheritance
Constructors
TensorSpan<T>(Array) |
Creates a new TensorSpan<T> over the provided Array. The new TensorSpan<T> will have a rank of 1 and a length equal to the length of the provided Array. |
TensorSpan<T>(Array, ReadOnlySpan<Int32>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new TensorSpan<T> over the provided Array using the specified start offsets, lengths, and strides. If the strides are not provided, they will be automatically calculated. |
TensorSpan<T>(Array, ReadOnlySpan<NIndex>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new TensorSpan<T> over the provided Array using the specified start offsets, lengths, and strides. If the strides are not provided, they will be automatically calculated. |
TensorSpan<T>(Span<T>) |
Creates a new TensorSpan<T> over the provided Span<T>. The new TensorSpan<T> will have a rank of 1 and a length equal to the length of the provided Span<T>. |
TensorSpan<T>(Span<T>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new TensorSpan<T> over the provided Span<T> using the specified lengths and strides. If the strides are not provided, they will be automatically calculated. |
TensorSpan<T>(T*, IntPtr) |
Creates a new span over the target unmanaged buffer. |
TensorSpan<T>(T*, IntPtr, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new span over the target unmanaged buffer. Clearly this is quite dangerous, because the length is not checked. But if this creation is correct, then all subsequent uses are correct. |
TensorSpan<T>(T[]) |
Creates a new span over the entirety of the target array. |
TensorSpan<T>(T[], Index, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new span over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive). |
TensorSpan<T>(T[], Int32, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new span over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive). |
Properties
Empty |
Gets an empty TensorSpan<T>. |
FlattenedLength |
Gets the number of items in the span. |
IsEmpty |
Gets a value indicating whether this TensorSpan<T> is empty. |
Item[ReadOnlySpan<IntPtr>] |
Returns a reference to specified element of the TensorSpan. |
Item[ReadOnlySpan<NIndex>] |
Returns a reference to specified element of the TensorSpan. |
Item[ReadOnlySpan<NRange>] |
Returns a slice of the TensorSpan. |
Lengths |
Gets the length of each dimension in this TensorSpan<T>. |
Rank |
Gets the rank, or number of dimensions, of this TensorSpan<T>. |
Strides |
Gets the strides of this TensorSpan<T>. |
Methods
Clear() |
Clears the contents of this span. |
CopyTo(TensorSpan<T>) |
Copies the contents of this span into destination span. If the source and destinations overlap, this method behaves as if the original values in a temporary location before the destination is overwritten. |
Equals(Object) |
Obsolete.
This method is not supported as spans cannot be boxed. To compare two spans, use operator ==. |
Fill(T) |
Fills the contents of this span with the given value. |
FlattenTo(Span<T>) |
Flattens the contents of this span into the provided Span<T>. |
GetEnumerator() |
Gets an enumerator for this span. |
GetHashCode() |
Obsolete.
This method is not supported as spans cannot be boxed. |
GetPinnableReference() |
Returns a reference to the 0th element of the TensorSpan. If the TensorSpan is empty, returns |
Slice(ReadOnlySpan<NIndex>) |
Returns a reference to specified element of the TensorSpan. |
Slice(ReadOnlySpan<NRange>) |
Forms a slice out of the given span |
ToString() |
For Span<T>, returns a new instance of string that represents the characters pointed to by the span. Otherwise, returns a String with the name of the type and the number of elements. |
TryCopyTo(TensorSpan<T>) |
Copies the contents of this span into destination span. If the source and destinations overlap, this method behaves as if the original values in a temporary location before the destination is overwritten. |
TryFlattenTo(Span<T>) |
Flattens the contents of this span into the provided Span<T>. |
Operators
Equality(TensorSpan<T>, TensorSpan<T>) |
Compares two System.Numerics.Tensors.TensorSpan<T> structs for equality. |
Implicit(T[] to TensorSpan<T>) | |
Implicit(TensorSpan<T> to ReadOnlyTensorSpan<T>) |
Converts a TensorSpan<T> to a ReadOnlyTensorSpan<T>. |
Inequality(TensorSpan<T>, TensorSpan<T>) |
Compares two System.Numerics.Tensors.TensorSpan<T> structs for inequality. |
Extension Methods
BroadcastTo<T>(TensorSpan<T>, TensorSpan<T>) |
Broadcasts the data from |
FilteredUpdate<T>(TensorSpan<T>, ReadOnlyTensorSpan<Boolean>, T) |
Updates the |
FilteredUpdate<T>(TensorSpan<T>, ReadOnlyTensorSpan<Boolean>, ReadOnlyTensorSpan<T>) |
Updates the |
Reshape<T>(TensorSpan<T>, ReadOnlySpan<IntPtr>) |
Reshapes the |
SetSlice<T>(TensorSpan<T>, ReadOnlyTensorSpan<T>, ReadOnlySpan<NRange>) |
Sets a slice of the given |
Squeeze<T>(TensorSpan<T>, Int32) | |
ToString<T>(TensorSpan<T>, ReadOnlySpan<IntPtr>) |
Creates a String representation of the TensorSpan<T>. |
TryBroadcastTo<T>(TensorSpan<T>, TensorSpan<T>) |
Broadcasts the data from |
Unsqueeze<T>(TensorSpan<T>, Int32) |
Inserts a new dimension of length 1 that will appear at the dimension position. |
Applies to
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for