Поделиться через


ReadOnlyTensorSpan<T> Struct

Definition

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::Numerics::Tensors::IReadOnlyTensor<System::Numerics::Tensors::ReadOnlyTensorSpan<T>, T>
generic <typename T>
public value class ReadOnlyTensorSpan
public readonly ref struct ReadOnlyTensorSpan<T> : System.Numerics.Tensors.IReadOnlyTensor<System.Numerics.Tensors.ReadOnlyTensorSpan<T>,T>
public readonly ref struct ReadOnlyTensorSpan<T>
type ReadOnlyTensorSpan<'T> = struct
    interface IReadOnlyTensor<ReadOnlyTensorSpan<'T>, 'T>
    interface IReadOnlyTensor
type ReadOnlyTensorSpan<'T> = struct
Public Structure ReadOnlyTensorSpan(Of T)
Implements IReadOnlyTensor(Of ReadOnlyTensorSpan(Of T), T)
Public Structure ReadOnlyTensorSpan(Of T)

Type Parameters

T

The type of the elements within the tensor span.

Inheritance
ReadOnlyTensorSpan<T>
Implements

Constructors

ReadOnlyTensorSpan<T>(Array, ReadOnlySpan<Int32>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new tensor span over the portion of the target array beginning at the specified start index and using the specified lengths and strides.

ReadOnlyTensorSpan<T>(Array)

Creates a new tensor span over the entirety of the target array.

ReadOnlyTensorSpan<T>(ReadOnlySpan<T>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new tensor span over the target span using the specified lengths and strides.

ReadOnlyTensorSpan<T>(ReadOnlySpan<T>, ReadOnlySpan<IntPtr>)

Creates a new tensor span over the target span using the specified lengths.

ReadOnlyTensorSpan<T>(ReadOnlySpan<T>)

Creates a new tensor span over the entirety of the target span.

ReadOnlyTensorSpan<T>(T[], Int32, 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.

ReadOnlyTensorSpan<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.

ReadOnlyTensorSpan<T>(T[], ReadOnlySpan<IntPtr>)

Creates a new tensor over the portion of the target array using the specified lengths.

ReadOnlyTensorSpan<T>(T[])

Creates a new tensor over the entirety of the target array.

ReadOnlyTensorSpan<T>(T*, IntPtr, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new tensor span over the target unmanaged buffer using the specified lengths and strides.

ReadOnlyTensorSpan<T>(T*, IntPtr, ReadOnlySpan<IntPtr>)

Creates a new tensor span over the target unmanaged buffer using the specified lengths.

ReadOnlyTensorSpan<T>(T*, IntPtr)

Creates a new tensor 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.

HasAnyDenseDimensions

Gets a value that indicates whether the current tensor has any dimension span where IsDense is true.

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 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 tensor span of TDerived to a tensor span of T.

CopyTo(TensorSpan<T>)

Copies the contents of the tensor into a destination tensor span.

Equals(Object)
Obsolete.

Calls to this method are not supported.

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 readonly tensor span.

GetHashCode()
Obsolete.

Calls to this method are not supported.

GetPinnableReference()

Returns a reference to the 0th element of the ReadOnlyTensorSpan. If the ReadOnlyTensorSpan is empty, returns null reference.

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()

Returns the string representation of the tensor span.

TryCopyTo(TensorSpan<T>)

Attempts to copy the contents of this tensor into a destination tensor span and returns a value to indicate whether or not the operation succeeded.

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<NIndex>, Int32, ReadOnlySpan<T>)

Tries to return a span that starts at the specified index and contains the specified number of items.

Operators

Equality(ReadOnlyTensorSpan<T>, ReadOnlyTensorSpan<T>)

Returns a value that indicates whether two tensor spans are equal.

Implicit(T[] to ReadOnlyTensorSpan<T>)
Inequality(ReadOnlyTensorSpan<T>, ReadOnlyTensorSpan<T>)

Returns a value that indicates whether two tensor spans are not equal.

Explicit Interface Implementations

IReadOnlyTensor.Item[ReadOnlySpan<IntPtr>]
IReadOnlyTensor.Item[ReadOnlySpan<NIndex>]
IReadOnlyTensor<ReadOnlyTensorSpan<T>,T>.AsReadOnlyTensorSpan()
IReadOnlyTensor<ReadOnlyTensorSpan<T>,T>.AsReadOnlyTensorSpan(ReadOnlySpan<IntPtr>)
IReadOnlyTensor<ReadOnlyTensorSpan<T>,T>.AsReadOnlyTensorSpan(ReadOnlySpan<NIndex>)
IReadOnlyTensor<ReadOnlyTensorSpan<T>,T>.AsReadOnlyTensorSpan(ReadOnlySpan<NRange>)
IReadOnlyTensor<ReadOnlyTensorSpan<T>,T>.CopyTo(TensorSpan<T>)
IReadOnlyTensor<ReadOnlyTensorSpan<T>,T>.ToDenseTensor()
IReadOnlyTensor<ReadOnlyTensorSpan<T>,T>.TryCopyTo(TensorSpan<T>)

Extension Methods

BroadcastTo<T>(ReadOnlyTensorSpan<T>, TensorSpan<T>)

Broadcast the data from source to destination.

Reshape<T>(ReadOnlyTensorSpan<T>, ReadOnlySpan<IntPtr>)

Reshapes the tensor tensor to the specified lengths. If one of the lengths is -1, it will be calculated automatically. Does not change the length of the underlying memory nor does it allocate new memory. If the new shape is not compatible with the old shape, an exception is thrown.

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 tensor.

SqueezeDimension<T>(ReadOnlyTensorSpan<T>, Int32)

Removes axis of length one from the tensor for the given dimension. If the dimension is not of length one it will throw an exception.

ToString<T>(ReadOnlyTensorSpan<T>, ReadOnlySpan<IntPtr>)

Creates a String representation of the ReadOnlyTensorSpan<T>."/>

TryBroadcastTo<T>(ReadOnlyTensorSpan<T>, TensorSpan<T>)

Broadcast the data from tensor to the smallest broadcastable shape compatible with destination and stores it in destination If the shapes are not compatible, false is returned.

Unsqueeze<T>(ReadOnlyTensorSpan<T>, Int32)

Insert a new dimension of length 1 that will appear at the dimension position.

Applies to