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>
[System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5001", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
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>
[<System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5001", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type Tensor<'T> = class
interface ITensor<Tensor<'T>, 'T>
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>
- Attributes
- Implements
Properties
Empty |
The Empty Tensor. |
FlattenedLength |
The number of items in the Tensor<T>. |
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. |
Item[Tensor<Boolean>] | |
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
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>) |
Copies the contents of this tensor 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) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
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>. |
GetEnumerator() |
Gets an IEnumerator<T> for the Tensor<T>. |
GetHashCode() |
Gets the hash code for the Tensor<T>. |
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. |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
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 |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
ToString(ReadOnlySpan<IntPtr>) |
Creates a String representation of the TensorSpan<T>."/> |
TryCopyTo(TensorSpan<T>) |
Copies the contents of this tensor 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 Tensor into the provided Span<T>. |
Operators
Implicit(T[] to Tensor<T>) | |
Implicit(Tensor<T> to ReadOnlyTensorSpan<T>) | |
Implicit(Tensor<T> to TensorSpan<T>) |
Explicit Interface Implementations
IEnumerable.GetEnumerator() |
Gets an IEnumerator for the Tensor<T>."/> |
IEnumerable<T>.GetEnumerator() |
Gets an IEnumerator<T> for the Tensor<T>. |
IReadOnlyTensor<Tensor<T>,T>.GetPinnableReference() |
Returns a reference to the 0th element of the ReadOnlyTensor. If the ReadOnlyTensor is empty, returns null reference. It can be used for pinning and is required to support the use of ReadOnlyTensor within a fixed statement. |
IReadOnlyTensor<Tensor<T>,T>.Item[ReadOnlySpan<IntPtr>] |
Returns the specified element of the ReadOnlyTensor. |
IReadOnlyTensor<Tensor<T>,T>.Item[ReadOnlySpan<NIndex>] |
Returns the specified element of the ReadOnlyTensor. |
IReadOnlyTensor<Tensor<T>,T>.Item[ReadOnlySpan<NRange>] |
Returns a slice of the ReadOnlyTensor. |
IReadOnlyTensor<Tensor<T>,T>.Lengths |
Gets the length of each dimension in this Tensor<T>. |
IReadOnlyTensor<Tensor<T>,T>.Strides |
Gets the strides of each dimension in this Tensor<T>. |
ITensor<Tensor<T>,T>.Create(ReadOnlySpan<IntPtr>, Boolean) |
Creates a Tensor<T> and initializes it with the default value of T. If |
ITensor<Tensor<T>,T>.Create(ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>, Boolean) |
Creates a Tensor<T> and initializes it with the default value of T. If |
ITensor<Tensor<T>,T>.CreateUninitialized(ReadOnlySpan<IntPtr>, Boolean) |
Creates a Tensor<T> and does not initialize it. If |
ITensor<Tensor<T>,T>.CreateUninitialized(ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>, Boolean) |
Creates a Tensor<T> and does not initialize it. If |
ITensor<Tensor<T>,T>.IsReadOnly | |
ITensor<Tensor<T>,T>.Item[ReadOnlySpan<IntPtr>] |
Returns the specified element of the Tensor. |
ITensor<Tensor<T>,T>.Item[ReadOnlySpan<NIndex>] |
Returns the specified element of the Tensor. |
Extension Methods
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. |
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. |
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>(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. |
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. |
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. |
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 |
ToString<T>(Tensor<T>, ReadOnlySpan<IntPtr>) | |
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. |
Applies to
.NET