Tensor<T> Class
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 tensor.
generic <typename T>
public ref class Tensor sealed : System::Collections::Generic::IEnumerable<T>, System::Numerics::Tensors::IReadOnlyTensor<System::Numerics::Tensors::Tensor<T> ^, T>, System::Numerics::Tensors::ITensor<System::Numerics::Tensors::Tensor<T> ^, T>
public sealed class Tensor<T> : System.Collections.Generic.IEnumerable<T>, System.Numerics.Tensors.IReadOnlyTensor<System.Numerics.Tensors.Tensor<T>,T>, System.Numerics.Tensors.ITensor<System.Numerics.Tensors.Tensor<T>,T>
type Tensor<'T> = class
interface ITensor<Tensor<'T>, 'T>
interface ITensor
interface IReadOnlyTensor
interface IReadOnlyTensor<Tensor<'T>, 'T>
interface seq<'T>
interface IEnumerable
Public NotInheritable Class Tensor(Of T)
Implements IEnumerable(Of T), IReadOnlyTensor(Of Tensor(Of T), T), ITensor(Of Tensor(Of T), T)
Type Parameters
- T
- Inheritance
-
Tensor<T>
- Implements
Properties
| Name | Description |
|---|---|
| Empty |
Gets an empty tensor. |
| FlattenedLength |
The number of items in the Tensor<T>. |
| 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 Tensor<T> is empty. |
| IsPinned |
Gets a value indicating whether the backing memory of the Tensor<T> is pinned."/> |
| Item[ReadOnlySpan<IntPtr>] |
Returns a reference to specified element of the Tensor. |
| Item[ReadOnlySpan<NIndex>] |
Returns a reference to specified element of the Tensor. |
| Item[ReadOnlySpan<NRange>] |
Returns a slice of the Tensor. |
| Lengths |
Gets the length of each dimension in this Tensor<T>. |
| Rank |
Gets a value indicating the rank, or number of dimensions, of this Tensor<T>. |
| Strides |
Gets the strides of each dimension in this Tensor<T>. |
Methods
| Name | Description |
|---|---|
| AsReadOnlyTensorSpan() |
Converts this Tensor<T> to a ReadOnlyTensorSpan<T> pointing to the same backing memory."/> |
| AsReadOnlyTensorSpan(ReadOnlySpan<IntPtr>) |
Converts this Tensor<T> to a ReadOnlyTensorSpan<T> pointing to the same backing memory based on the provided start locations."/> |
| AsReadOnlyTensorSpan(ReadOnlySpan<NIndex>) |
Converts this Tensor<T> to a ReadOnlyTensorSpan<T> pointing to the same backing memory based on the provided start indexes."/> |
| AsReadOnlyTensorSpan(ReadOnlySpan<NRange>) |
Converts this Tensor<T> to a ReadOnlyTensorSpan<T> pointing to the same backing memory based on the provided ranges."/> |
| AsTensorSpan() |
Converts this Tensor<T> to a TensorSpan<T> pointing to the same backing memory."/> |
| AsTensorSpan(ReadOnlySpan<IntPtr>) |
Converts this Tensor<T> to a TensorSpan<T> pointing to the same backing memory based on the provided start locations."/> |
| AsTensorSpan(ReadOnlySpan<NIndex>) |
Converts this Tensor<T> to a TensorSpan<T> pointing to the same backing memory based on the provided start indexes."/> |
| AsTensorSpan(ReadOnlySpan<NRange>) |
Converts this Tensor<T> to a TensorSpan<T> pointing to the same backing memory based on the provided ranges."/> |
| Clear() |
Clears the contents of this tensor. |
| CopyTo(TensorSpan<T>) | |
| Fill(T) |
Fills the contents of this span with the given value. |
| FlattenTo(Span<T>) |
Flattens the contents of this Tensor 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 readonly tensor. |
| GetPinnableReference() |
Returns a reference to the 0th element of the Tensor. If the Tensor is empty, returns null reference. It can be used for pinning and is required to support the use of Tensor within a fixed statement. |
| GetPinnedHandle() |
Pins and gets a MemoryHandle to the backing memory. |
| 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 given tensor |
| Slice(ReadOnlySpan<NIndex>) |
Forms a slice out of the given tensor |
| Slice(ReadOnlySpan<NRange>) |
Forms a slice out of the given tensor |
| ToDenseTensor() |
Creates a dense tensor from the elements of the current tensor. |
| ToString() |
Returns the string representation of the tensor. |
| ToString(ReadOnlySpan<IntPtr>) |
Creates a String representation of the TensorSpan<T>."/> |
| TryCopyTo(TensorSpan<T>) | |
| TryFlattenTo(Span<T>) |
Flattens the contents of this Tensor 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 |
|---|---|
| Implicit(T[] to Tensor<T>) |
Defines an implicit conversion of an array to a tensor. |
| Implicit(Tensor<T> to ReadOnlyTensorSpan<T>) | System.Numerics.Tensors.TensorSpan`1.op_Implicit(System.Numerics.Tensors.TensorSpan{`0}@)~System.Numerics.Tensors.ReadOnlyTensorSpan{`0} |
| Implicit(Tensor<T> to TensorSpan<T>) |
Defines an implicit conversion of a tensor to a tensor span. |
Explicit Interface Implementations
Extension Methods
| Name | Description |
|---|---|
| BroadcastTo<T>(Tensor<T>, TensorSpan<T>) |
Broadcast the data from |
| PermuteDimensions<T>(Tensor<T>, ReadOnlySpan<Int32>) |
Swaps the dimensions of the |
| Reshape<T>(Tensor<T>, ReadOnlySpan<IntPtr>) |
Reshapes the |
| SetSlice<T>(Tensor<T>, ReadOnlyTensorSpan<T>, ReadOnlySpan<NRange>) |
Sets a slice of the given |
| Squeeze<T>(Tensor<T>) |
Removes all dimensions of length one from the |
| SqueezeDimension<T>(Tensor<T>, Int32) |
Removes axis of length one from the |
| ToAsyncEnumerable<TSource>(IEnumerable<TSource>) |
Creates a new IAsyncEnumerable<T> that iterates through |
| ToFrozenDictionary<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>) |
Creates a FrozenDictionary<TKey,TValue> from an IEnumerable<T> according to specified key selector and element selector functions. |
| ToFrozenDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>) |
Creates a FrozenDictionary<TKey,TValue> from an IEnumerable<T> according to specified key selector function. |
| ToFrozenSet<T>(IEnumerable<T>, IEqualityComparer<T>) |
Creates a FrozenSet<T> with the specified values. |
| ToImmutableArray<TSource>(IEnumerable<TSource>) |
Creates an immutable array from the specified collection. |
| ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>, IEqualityComparer<TValue>) |
Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key and value comparers. |
| ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>) |
Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key comparer. |
| ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>) |
Enumerates and transforms a sequence, and produces an immutable dictionary of its contents. |
| ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>) |
Constructs an immutable dictionary based on some transformation of a sequence. |
| ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>) |
Constructs an immutable dictionary from an existing collection of elements, applying a transformation function to the source keys. |
| ToImmutableHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>) |
Enumerates a sequence, produces an immutable hash set of its contents, and uses the specified equality comparer for the set type. |
| ToImmutableHashSet<TSource>(IEnumerable<TSource>) |
Enumerates a sequence and produces an immutable hash set of its contents. |
| ToImmutableList<TSource>(IEnumerable<TSource>) |
Enumerates a sequence and produces an immutable list of its contents. |
| ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IComparer<TKey>, IEqualityComparer<TValue>) |
Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key and value comparers. |
| ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IComparer<TKey>) |
Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key comparer. |
| ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>) |
Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents. |
| ToImmutableSortedSet<TSource>(IEnumerable<TSource>, IComparer<TSource>) |
Enumerates a sequence, produces an immutable sorted set of its contents, and uses the specified comparer. |
| ToImmutableSortedSet<TSource>(IEnumerable<TSource>) |
Enumerates a sequence and produces an immutable sorted set of its contents. |
| TryBroadcastTo<T>(Tensor<T>, TensorSpan<T>) |
Broadcast the data from |
| Unsqueeze<T>(Tensor<T>, Int32) |
Insert a new dimension of length 1 that will appear at the dimension position. |
Extension Operators
| Name | Description |
|---|---|
| Addition(Tensor<TScalar>, Tensor<TScalar>) |
Performs element-wise addition between two tensors. |
| Addition(Tensor<TScalar>, TScalar) |
Performs element-wise addition between a tensor and scalar. |
| Addition(TScalar, Tensor<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(Tensor<TScalar>, Tensor<TScalar>) |
Performs bitwise-and between two tensors. |
| BitwiseAnd(Tensor<TScalar>, TScalar) |
Performs bitwise-and between a tensor and scalar. |
| BitwiseAnd(TScalar, Tensor<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(Tensor<TScalar>, Tensor<TScalar>) |
Performs bitwise-or between two tensors. |
| BitwiseOr(Tensor<TScalar>, TScalar) |
Performs bitwise-or between a tensor and scalar. |
| BitwiseOr(TScalar, Tensor<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(Tensor<TScalar>, Tensor<TScalar>) |
Performs element-wise division between two tensors. |
| Division(Tensor<TScalar>, TScalar) |
Performs element-wise division between a tensor and scalar. |
| Division(TScalar, Tensor<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(Tensor<TScalar>, Tensor<TScalar>) |
Performs exclusive-or between two tensors. |
| ExclusiveOr(Tensor<TScalar>, TScalar) |
Performs exclusive-or between a tensor and scalar. |
| ExclusiveOr(TScalar, Tensor<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(Tensor<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(Tensor<TScalar>, Tensor<TScalar>) |
Performs element-wise multiplication between two tensors. |
| Multiply(Tensor<TScalar>, TScalar) |
Performs element-wise multiplication between a tensor and scalar. |
| Multiply(TScalar, Tensor<TScalar>) |
Performs element-wise multiplication between a tensor and scalar. |
| OnesComplement(Tensor<TScalar>) |
Performs a one's complement on a tensor. |
| RightShift(Tensor<TScalar>, Int32) |
Performs an element-wise left shift on a tensor. |
| RightShiftAssignment(Int32) |
Performs in-place element-wise left shift on a tensor. |
| Subtraction(Tensor<TScalar>, Tensor<TScalar>) |
Performs element-wise subtraction between two tensors. |
| Subtraction(Tensor<TScalar>, TScalar) |
Performs element-wise subtraction between a tensor and scalar. |
| Subtraction(TScalar, Tensor<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(Tensor<TScalar>) |
Performs element-wise unary negation on a tensor. |
| UnaryPlus(Tensor<TScalar>) |
Performs element-wise unary plus on a tensor. |
| UnsignedRightShift(Tensor<TScalar>, Int32) |
Performs an element-wise left shift on a tensor. |
| UnsignedRightShiftAssignment(Int32) |
Performs in-place element-wise left shift on a tensor. |