ReadOnlyTensorSpan<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 ReadOnlyTensorSpan
[System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5001", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public readonly ref struct ReadOnlyTensorSpan<T>
[<System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5001", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type ReadOnlyTensorSpan<'T> = struct
Public Structure ReadOnlyTensorSpan(Of T)
Type Parameters
- T
- Inheritance
- Attributes
Constructors
ReadOnlyTensorSpan<T>(Array, ReadOnlySpan<Int32>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new ReadOnlyTensorSpan<T> over the provided Array using the specified start offsets, lengths, and strides. |
ReadOnlyTensorSpan<T>(Array, ReadOnlySpan<NIndex>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new ReadOnlyTensorSpan<T> over the provided Array using the specified start offsets, lengths, and strides. |
ReadOnlyTensorSpan<T>(Array) |
Creates a new ReadOnlyTensorSpan<T> over the provided Array. The new ReadOnlyTensorSpan<T> will have a rank of 1 and a length equal to the length of the provided Array. |
ReadOnlyTensorSpan<T>(ReadOnlySpan<T>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new ReadOnlyTensorSpan<T> over the provided Span<T> using the specified lengths and strides. |
ReadOnlyTensorSpan<T>(ReadOnlySpan<T>) |
Creates a new ReadOnlyTensorSpan<T> over the provided ReadOnlySpan<T>. The new ReadOnlyTensorSpan<T> will have a rank of 1 and a length equal to the length of the provided ReadOnlySpan<T>. |
ReadOnlyTensorSpan<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). |
ReadOnlyTensorSpan<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). |
ReadOnlyTensorSpan<T>(T[]) |
Creates a new span over the entirety of the target array. |
ReadOnlyTensorSpan<T>(T*, IntPtr, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new span over the target unmanaged buffer. |
ReadOnlyTensorSpan<T>(T*, IntPtr) |
Creates a new span over the target unmanaged buffer. |
Properties
Empty |
Returns a 0-length read-only span whose base is the null pointer. |
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 ReadOnlyTensorSpan. |
Item[ReadOnlySpan<NIndex>] |
Returns a reference to specified element of the ReadOnlyTensorSpan. |
Item[ReadOnlySpan<NRange>] |
Returns a slice of the ReadOnlyTensorSpan. |
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
CastUp<TDerived>(ReadOnlyTensorSpan<TDerived>) |
Casts a read-only span of |
CopyTo(TensorSpan<T>) |
Copies the contents of this read-only span into destination span. If the source and destinations overlap, this method behaves as if the original values are 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 ==. |
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 ReadOnlyTensorSpan. If the ReadOnlyTensorSpan is empty, returns null reference. |
Slice(ReadOnlySpan<NIndex>) |
Returns a reference to specified element of the TensorSpan. |
Slice(ReadOnlySpan<NRange>) |
Forms a slice out of the given span. |
ToString() |
Returns a String with the name of the type and the number of elements. |
TryCopyTo(TensorSpan<T>) |
Copies the contents of this read-only span into destination span. |
TryFlattenTo(Span<T>) |
Flattens the contents of this span into the provided Span<T>. |
Operators
Equality(ReadOnlyTensorSpan<T>, ReadOnlyTensorSpan<T>) |
Compares the given spans and returns true if left and right point at the same memory and have the same length. This operator does not check to see if the contents are equal. |
Implicit(T[] to ReadOnlyTensorSpan<T>) | |
Inequality(ReadOnlyTensorSpan<T>, ReadOnlyTensorSpan<T>) |
Compares the given spans and returns false if left and right point at the same memory and have the same length. This opertor does not check to see if the contents are equal. |
Extension Methods
BroadcastTo<T>(ReadOnlyTensorSpan<T>, TensorSpan<T>) |
Broadcast the data from |
Reshape<T>(ReadOnlyTensorSpan<T>, ReadOnlySpan<IntPtr>) |
Reshapes the |
SequenceEqual<T>(ReadOnlyTensorSpan<T>, ReadOnlyTensorSpan<T>) |
Determines whether two sequences are equal by comparing the elements using IEquatable{T}.Equals(T). |
Squeeze<T>(ReadOnlyTensorSpan<T>) |
Removes all dimensions of length one from the |
SqueezeDimension<T>(ReadOnlyTensorSpan<T>, Int32) |
Removes axis of length one from the |
ToString<T>(ReadOnlyTensorSpan<T>, ReadOnlySpan<IntPtr>) |
Creates a String representation of the ReadOnlyTensorSpan<T>."/> |
TryBroadcastTo<T>(ReadOnlyTensorSpan<T>, TensorSpan<T>) |
Broadcast the data from |
Unsqueeze<T>(ReadOnlyTensorSpan<T>, Int32) |
Insert a new dimension of length 1 that will appear at the dimension position. |