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 : System::Numerics::Tensors::IReadOnlyTensor<System::Numerics::Tensors::TensorSpan<T>, T>, System::Numerics::Tensors::ITensor<System::Numerics::Tensors::TensorSpan<T>, T>
generic <typename T>
public value class TensorSpan
public readonly ref struct TensorSpan<T> : System.Numerics.Tensors.IReadOnlyTensor<System.Numerics.Tensors.TensorSpan<T>,T>, System.Numerics.Tensors.ITensor<System.Numerics.Tensors.TensorSpan<T>,T>
public readonly ref struct TensorSpan<T>
type TensorSpan<'T> = struct
interface ITensor<TensorSpan<'T>, 'T>
interface ITensor
interface IReadOnlyTensor
interface IReadOnlyTensor<TensorSpan<'T>, 'T>
type TensorSpan<'T> = struct
Public Structure TensorSpan(Of T)
Implements IReadOnlyTensor(Of TensorSpan(Of T), T), ITensor(Of TensorSpan(Of T), T)
Public Structure TensorSpan(Of T)
Type Parameters
- T
The type of the elements within the tensor span.
- Inheritance
- Implements
Constructors
| Name | Description |
|---|---|
| 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. |
| 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>(Span<T>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new TensorSpan<T> over the provided Span<T> using the specified lengths and strides. |
| TensorSpan<T>(Span<T>, ReadOnlySpan<IntPtr>) |
Creates a new tensor span over the target span using the specified lengths. |
| 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>(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). |
| TensorSpan<T>(T[], ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new tensor over the portion of the target array beginning at the specified start index and using the specified lengths and strides. |
| TensorSpan<T>(T[], ReadOnlySpan<IntPtr>) |
Creates a new tensor over the portion of the target array using the specified lengths. |
| TensorSpan<T>(T[]) |
Creates a new span over the entirety of the target array. |
| TensorSpan<T>(T*, IntPtr, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>) |
Creates a new span over the target unmanaged buffer. |
| TensorSpan<T>(T*, IntPtr, ReadOnlySpan<IntPtr>) |
Creates a new tensor span over the target unmanaged buffer using the specified lengths. |
| TensorSpan<T>(T*, IntPtr) |
Creates a new span over the target unmanaged buffer. |
Properties
| Name | Description |
|---|---|
| Empty |
Returns an empty TensorSpan<T> |
| FlattenedLength |
The number of items in the span. |
| HasAnyDenseDimensions |
Gets a value that indicates whether the current tensor has any dimension span where IsDense is |
| IsDense |
Gets a value that indicates whether the current tensor is dense. |
| IsEmpty |
Gets a value indicating whether this TensorSpan<T> is empty. |
| IsPinned |
Gets a value that indicates whether the underlying buffer is pinned. |
| 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, aka the number of dimensions, of this TensorSpan<T>. |
| Strides |
Gets the strides of this TensorSpan<T> |
Methods
| Name | Description |
|---|---|
| AsReadOnlyTensorSpan() |
Creates a new readonly tensor span over the tensor. |
| AsReadOnlyTensorSpan(ReadOnlySpan<IntPtr>) |
Creates a new readonly tensor span over a portion of the tensor starting at a specified position to the end of the tensor. |
| AsReadOnlyTensorSpan(ReadOnlySpan<NIndex>) |
Creates a read-only tensor span for the specified start indexes. |
| AsReadOnlyTensorSpan(ReadOnlySpan<NRange>) |
Creates a new readonly tensor span over a portion of the tensor defined by the specified range. |
| Clear() |
Clears the contents of this span. |
| CopyTo(TensorSpan<T>) | |
| 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>. |
| GetDimensionSpan(Int32) |
Returns a span that can be used to access the flattened elements for a given dimension. |
| GetEnumerator() |
Gets an enumerator for the tensor 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 null reference. It can be used for pinning and is required to support the use of span within a fixed statement. |
| GetSpan(ReadOnlySpan<IntPtr>, Int32) |
Return a span that starts at the specified index and contains the specified number of items. |
| GetSpan(ReadOnlySpan<NIndex>, Int32) |
Return a span that starts at the specified index and contains the specified number of items. |
| Slice(ReadOnlySpan<IntPtr>) |
Forms a slice out of the current tensor that begins at a specified index. |
| 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. |
| ToString(ReadOnlySpan<IntPtr>) |
Creates a String representation of the tensor. |
| TryCopyTo(TensorSpan<T>) | |
| TryFlattenTo(Span<T>) |
Flattens the contents of this span into the provided Span<T>. |
| TryGetSpan(ReadOnlySpan<IntPtr>, Int32, ReadOnlySpan<T>) |
Tries to return a span that starts at the specified index and contains the specified number of items. |
| TryGetSpan(ReadOnlySpan<IntPtr>, Int32, Span<T>) |
Tries to return a span that starts at the specified index and contains the specified number of items. |
| TryGetSpan(ReadOnlySpan<NIndex>, Int32, ReadOnlySpan<T>) |
Tries to return a span that starts at the specified index and contains the specified number of items. |
| TryGetSpan(ReadOnlySpan<NIndex>, Int32, Span<T>) |
Tries to return a span that starts at the specified index and contains the specified number of items. |
Operators
| Name | Description |
|---|---|
| Equality(TensorSpan<T>, TensorSpan<T>) |
Returns a value that indicates whether two tensor spans are equal. |
| Implicit(T[] to TensorSpan<T>) |
Defines an implicit conversion of an array to a tensor span. |
| Implicit(TensorSpan<T> to ReadOnlyTensorSpan<T>) |
Defines an implicit conversion of a tensor to a readonly tensor span. |
| Inequality(TensorSpan<T>, TensorSpan<T>) |
Returns a value that indicates whether two tensor spans are not equal. |
Explicit Interface Implementations
Extension Methods
| Name | Description |
|---|---|
| BroadcastTo<T>(TensorSpan<T>, TensorSpan<T>) |
Broadcast the data from |
| FilteredUpdate<T>(TensorSpan<T>, ReadOnlyTensorSpan<Boolean>, ReadOnlyTensorSpan<T>) |
Updates the |
| FilteredUpdate<T>(TensorSpan<T>, ReadOnlyTensorSpan<Boolean>, T) |
Updates the |
| Reshape<T>(TensorSpan<T>, ReadOnlySpan<IntPtr>) |
Reshapes the |
| SequenceEqual<T>(TensorSpan<T>, ReadOnlyTensorSpan<T>) |
Determines whether two sequences are equal by comparing the elements using IEquatable{T}.Equals(T). |
| SetSlice<T>(TensorSpan<T>, ReadOnlyTensorSpan<T>, ReadOnlySpan<NRange>) |
Sets a slice of the given |
| Squeeze<T>(TensorSpan<T>) |
Removes all dimensions of length one from the |
| SqueezeDimension<T>(TensorSpan<T>, Int32) |
Removes axis of length one from the |
| TryBroadcastTo<T>(TensorSpan<T>, TensorSpan<T>) |
Broadcast the data from |
| Unsqueeze<T>(TensorSpan<T>, Int32) |
Insert a new dimension of length 1 that will appear at the dimension position. |
Extension Operators
| Name | Description |
|---|---|
| Addition(TensorSpan<TScalar>, TensorSpan<TScalar>) |
Performs element-wise addition between two tensors. |
| Addition(TensorSpan<TScalar>, TScalar) |
Performs element-wise addition between a tensor and scalar. |
| Addition(TScalar, TensorSpan<TScalar>) |
Performs element-wise addition between a tensor and scalar. |
| AdditionAssignment(ReadOnlyTensorSpan<TScalar>) |
Performs in-place element-wise addition between two tensors. |
| AdditionAssignment(TScalar) |
Performs in-place element-wise addition between a tensor and scalar. |
| BitwiseAnd(TensorSpan<TScalar>, TensorSpan<TScalar>) |
Performs bitwise-and between two tensors. |
| BitwiseAnd(TensorSpan<TScalar>, TScalar) |
Performs bitwise-and between a tensor and scalar. |
| BitwiseAnd(TScalar, TensorSpan<TScalar>) |
Performs bitwise-and between a tensor and scalar. |
| BitwiseAndAssignment(ReadOnlyTensorSpan<TScalar>) |
Performs in-place bitwise-and between two tensors. |
| BitwiseAndAssignment(TScalar) |
Performs in-place bitwise-and between a tensor and scalar. |
| BitwiseOr(TensorSpan<TScalar>, TensorSpan<TScalar>) |
Performs bitwise-or between two tensors. |
| BitwiseOr(TensorSpan<TScalar>, TScalar) |
Performs bitwise-or between a tensor and scalar. |
| BitwiseOr(TScalar, TensorSpan<TScalar>) |
Performs bitwise-or between a tensor and scalar. |
| BitwiseOrAssignment(ReadOnlyTensorSpan<TScalar>) |
Performs in-place bitwise-or between two tensors. |
| BitwiseOrAssignment(TScalar) |
Performs in-place bitwise-or between a tensor and scalar. |
| DecrementAssignment |
Performs in-place decrement on a tensor. |
| Division(TensorSpan<TScalar>, TensorSpan<TScalar>) |
Performs element-wise division between two tensors. |
| Division(TensorSpan<TScalar>, TScalar) |
Performs element-wise division between a tensor and scalar. |
| Division(TScalar, TensorSpan<TScalar>) |
Performs element-wise division between a tensor and scalar. |
| DivisionAssignment(ReadOnlyTensorSpan<TScalar>) |
Performs in-place element-wise division between two tensors. |
| DivisionAssignment(TScalar) |
Performs in-place element-wise division between a tensor and scalar. |
| ExclusiveOr(TensorSpan<TScalar>, TensorSpan<TScalar>) |
Performs exclusive-or between two tensors. |
| ExclusiveOr(TensorSpan<TScalar>, TScalar) |
Performs exclusive-or between a tensor and scalar. |
| ExclusiveOr(TScalar, TensorSpan<TScalar>) |
Performs exclusive-or between a tensor and scalar. |
| ExclusiveOrAssignment(ReadOnlyTensorSpan<TScalar>) |
Performs in-place exclusive-or between two tensors. |
| ExclusiveOrAssignment(TScalar) |
Performs in-place exclusive-or between a tensor and scalar. |
| IncrementAssignment |
Performs in-place increment on a tensor. |
| LeftShift(TensorSpan<TScalar>, Int32) |
Performs an element-wise left shift on a tensor. |
| LeftShiftAssignment(Int32) |
Performs in-place element-wise left shift on a tensor. |
| MultiplicationAssignment(ReadOnlyTensorSpan<TScalar>) |
Performs in-place element-wise multiplication between two tensors. |
| MultiplicationAssignment(TScalar) |
Performs in-place element-wise multiplication between a tensor and scalar. |
| Multiply(TensorSpan<TScalar>, TensorSpan<TScalar>) |
Performs element-wise multiplication between two tensors. |
| Multiply(TensorSpan<TScalar>, TScalar) |
Performs element-wise multiplication between a tensor and scalar. |
| Multiply(TScalar, TensorSpan<TScalar>) |
Performs element-wise multiplication between a tensor and scalar. |
| OnesComplement(TensorSpan<TScalar>) |
Performs a one's complement on a tensor. |
| RightShift(TensorSpan<TScalar>, Int32) |
Performs an element-wise left shift on a tensor. |
| RightShiftAssignment(Int32) |
Performs in-place element-wise arithmetic right shift on a tensor. |
| Subtraction(TensorSpan<TScalar>, TensorSpan<TScalar>) |
Performs element-wise subtraction between two tensors. |
| Subtraction(TensorSpan<TScalar>, TScalar) |
Performs element-wise subtraction between a tensor and scalar. |
| Subtraction(TScalar, TensorSpan<TScalar>) |
Performs element-wise subtraction between a tensor and scalar. |
| SubtractionAssignment(ReadOnlyTensorSpan<TScalar>) |
Performs in-place element-wise subtraction between two tensors. |
| SubtractionAssignment(TScalar) |
Performs in-place element-wise subtraction between a tensor and scalar. |
| UnaryNegation(TensorSpan<TScalar>) |
Performs element-wise unary negation on a tensor. |
| UnaryPlus(TensorSpan<TScalar>) |
Performs element-wise unary plus on a tensor. |
| UnsignedRightShift(TensorSpan<TScalar>, Int32) |
Performs an element-wise left shift on a tensor. |
| UnsignedRightShiftAssignment(Int32) |
Performs in-place element-wise logical right shift on a tensor. |