11 instantiations of TensorShape
System.Numerics.Tensors (11)
System\Numerics\Tensors\netcore\TensorShape.cs (11)
57private static readonly TensorShape s_empty = new TensorShape(0, [0], [], TensorFlags.None); 876return new TensorShape(linearLength, lengths, strides, pinned ? TensorFlags.IsPinned : TensorFlags.None); 930TensorShape result = new TensorShape( 1035TensorShape result = new TensorShape(linearLength - computedOffset, lengths, strides, TensorFlags.None); 1060return new TensorShape(linearLength: -1, lengths: lengths, strides: strides, flags: flags); 1078return new TensorShape( 1093return new TensorShape(array.Length, lengths, strides, pinned ? TensorFlags.IsPinned : TensorFlags.None); 1115return new TensorShape(linearLength, lengths, strides, pinned ? TensorFlags.IsPinned : TensorFlags.None); 1146return new TensorShape( 1168return new TensorShape(linearLength, lengths, strides, flags); 1470TensorShape result = new TensorShape(
177 references to TensorShape
System.Numerics.Tensors (177)
System\Numerics\Tensors\netcore\ReadOnlyTensorDimensionSpan_1.cs (4)
17private readonly TensorShape _sliceShape; 24tensor = new ReadOnlyTensorSpan<T>(in tensor._reference, TensorShape.Normalize(tensor._shape)); 36_length = TensorShape.GetProduct(lengths[..dimension]); 38_sliceShape = TensorShape.Create((dimension != rank) ? lengths[dimension..] : [1], tensor.Strides[dimension..], tensor.IsPinned);
System\Numerics\Tensors\netcore\ReadOnlyTensorSpan_1.cs (23)
29internal readonly TensorShape _shape; 40_shape = TensorShape.Create(array); 75_shape = TensorShape.Create(array, lengths, strides); 99_shape = TensorShape.Create(array, start, lengths, strides); 111_shape = TensorShape.Create(ref reference, span.Length, pinned: false); 141_shape = TensorShape.Create(ref reference, span.Length, lengths, strides, pinned: false); 156_shape = TensorShape.Create(array); 186_shape = TensorShape.Create(array, start, lengths, strides, out nint linearOffset); 201_shape = TensorShape.Create(data, dataLength); 240_shape = TensorShape.Create(data, dataLength, lengths, strides); 246_shape = TensorShape.CreateForView(dataLength, lengths, strides, pinned); 250internal ReadOnlyTensorSpan(ref readonly T reference, scoped in TensorShape shape) 259get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNInt, nint>(indexes)); 265get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 411TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForSlice, nint>(startIndexes, out nint linearOffset); 421TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(startIndexes, out nint linearOffset); 431TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNRange, NRange>(ranges, out nint linearOffset); 457TensorShape.AreCompatible(destination._shape, _shape, false)) 480nint longestContiguousLength = _shape.GetLongestContiguousLength<TensorShape.GetOffsetAndLengthForNInt, nint>(startIndexes, out nint linearOffset); 496nint longestContiguousLength = _shape.GetLongestContiguousLength<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(startIndexes, out nint linearOffset);
System\Numerics\Tensors\netcore\Tensor_1.cs (15)
23internal readonly TensorShape _shape; 29_shape = TensorShape.Create(lengths, strides, pinned); 37_shape = TensorShape.Create(array); 45_shape = TensorShape.Create(array, lengths, strides); 53_shape = TensorShape.Create(array, start, lengths, strides, pinned); 58internal Tensor(T[] array, in TensorShape shape) 67internal Tensor(T[] array, int start, in TensorShape shape) 86get => ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_values), _start + _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNInt, nint>(indexes)); 92get => ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_values), _start + _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 223TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForSlice, nint>(startIndexes, out nint linearOffset); 238TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(startIndexes, out nint linearOffset); 253TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNRange, NRange>(ranges, out nint linearOffset);
System\Numerics\Tensors\netcore\Tensor.cs (41)
136ref readonly TensorShape shape = ref TensorShape.Normalize(tensors[0]._shape); 195ref readonly TensorShape shape = ref TensorShape.Normalize(tensors[0]._shape); 231ReadOnlySpan<nint> destinationLengths = TensorShape.Normalize(destination._shape).Lengths; 232if (!TensorShape.AreLengthsEquivalentExceptDimension(lengths, destinationLengths, dimension, out nint destinationAxisLength) 294alignedTarget = new TensorSpan<T>(ref destination._reference, TensorShape.WithRank(destination._shape, rank)); 325source = new ReadOnlyTensorSpan<T>(in source._reference, TensorShape.WithRank(source._shape, targetRank)); 342private static nint GetConcatenatedLength<T>(int dimension, scoped ReadOnlySpan<Tensor<T>> tensors, in TensorShape shape) 349ReadOnlySpan<nint> sourceLengths = TensorShape.Normalize(tensors[i]._shape).Lengths; 350if (!TensorShape.AreLengthsEquivalentExceptDimension(lengths, sourceLengths, dimension, out nint axisLength)) 464source = new ReadOnlyTensorSpan<T>(in source._reference, TensorShape.WithRank(source._shape, rank)); 471hasMore = TensorShape.AdjustToNextIndex(ranges, dimension - 1, destination.Lengths); 518TensorShape shape = TensorShape.Create(lengths, strides, pinned); 1738ref readonly TensorShape shape = ref TensorShape.Normalize(tensor._shape); 1770ref readonly TensorShape shape = ref TensorShape.Normalize(tensor._shape); 2035if (dimension < -1 || dimension >= TensorShape.Normalize(tensor._shape).Rank) 2047&& TensorShape.AreLayoutsTheSame(tensor._shape, destination._shape)) 2277|| !TensorShape.AreLengthsEquivalent(tensor.Lengths, other.Lengths)) 2302alignedOther = new ReadOnlyTensorSpan<T>(in other._reference, TensorShape.WithRank(other._shape, rank)); 2407ref readonly TensorShape shape = ref TensorShape.Normalize(tensor._shape); 2709ref readonly TensorShape shape = ref TensorShape.Normalize(tensors[0]._shape); 2742ref readonly TensorShape shape = ref TensorShape.Normalize(tensors[0]._shape); 2762ref readonly TensorShape shape = ref TensorShape.Normalize(tensors[0]._shape); 2767if (!TensorShape.AreLengthsEquivalent(lengths, TensorShape.Normalize(tensors[i]._shape).Lengths)) 2794alignedTarget = new TensorSpan<T>(ref destination._reference, TensorShape.WithRank(destination._shape, rank + 1)); 2881TensorShape tmpShape = TensorShape.Create(lengths[1..], tensor.Strides[1..], tensor.IsPinned); 3032if (!TensorShape.AreCompatible(destination._shape, tensor._shape, false)) 3100ref readonly TensorShape shape = ref TensorShape.Normalize(tensor._shape); 3145ref readonly TensorShape shape = ref TensorShape.Normalize(tensor._shape);
System\Numerics\Tensors\netcore\TensorDimensionSpan_1.cs (4)
17private readonly TensorShape _sliceShape; 24tensor = new TensorSpan<T>(ref tensor._reference, TensorShape.Normalize(tensor._shape)); 36_length = TensorShape.GetProduct(lengths[..dimension]); 38_sliceShape = TensorShape.Create((dimension != rank) ? lengths[dimension..] : [1], tensor.Strides[dimension..], tensor.IsPinned);
System\Numerics\Tensors\netcore\TensorOperation.cs (30)
37&& TensorShape.AreLayoutsTheSame(source._shape, destination._shape)) 401private static ReadOnlyTensorSpan<T> BroadcastSource<T>(in ReadOnlyTensorSpan<T> source, in TensorShape destination) 420TensorShape shape = TensorShape.Create(in source._reference, source._shape.LinearLength, destination.Lengths, strides, source.IsPinned); 425internal static int GetDenseSliceDimension(in TensorShape source, in TensorShape destination, in TensorShape other = default, 684TensorShape destinationShape = GetBroadcastShape(x._shape, y._shape); 747private static TensorShape GetBroadcastShape(in TensorShape x, in TensorShape y) 749x = ref TensorShape.Normalize(x); 750y = ref TensorShape.Normalize(y); 752if (TensorShape.AreLengthsTheSame(x, y)) 768TensorShape shape = TensorShape.Create(lengths, [], pinned: false); 1240TensorShape destinationShape = GetBroadcastShape(x._shape, y._shape); 1455if (!TensorShape.AreCompatible(lengths, x._shape)) 1462if (!TensorShape.AreCompatible(x._shape, y._shape, true)) 1469if (!TensorShape.AreCompatible(destination._shape, x._shape, false)) 1476if (TensorShape.AreCompatible(x._shape, y._shape, true)) 1478if (TensorShape.AreCompatible(destination._shape, x._shape, false)) 1480if (TensorShape.AreCompatible(destination._shape, y._shape, false)) 1493if (TensorShape.AreCompatible(x._shape, y._shape, true)) 1495ref readonly TensorShape xShape = ref TensorShape.Normalize(x._shape); 1496ref readonly TensorShape yShape = ref TensorShape.Normalize(y._shape); 3942private TensorShape.InlineBuffer<T> _inline; 3946if (rank > TensorShape.MaxInlineRank)
System\Numerics\Tensors\netcore\TensorShape.cs (38)
44internal readonly struct TensorShape : IEquatable<TensorShape> 57private static readonly TensorShape s_empty = new TensorShape(0, [0], [], TensorFlags.None); 451public static bool operator ==(in TensorShape left, in TensorShape right) 492public static bool operator !=(in TensorShape left, in TensorShape right) => !(left == right); 494public nint AdjustToNextIndex(in TensorShape destinationShape, nint linearOffset, Span<nint> indexes) 559public nint AdjustToPreviousIndex(in TensorShape destinationShape, nint linearOffset, Span<nint> indexes) 647public static bool AreCompatible(in TensorShape shape1, in TensorShape shape2, bool allowBidirectional) 668ref readonly TensorShape tmpShape = ref shape1; 733public static bool AreCompatible(in ReadOnlySpan<nint> shape1Lengths, in TensorShape shape2) 784public static ref readonly TensorShape Normalize(in TensorShape shape) 847internal static TensorShape WithRank(in TensorShape shape, int rank) 866TensorShape result = CreateForView(shape.LinearLength, lengths, strides, shape.IsPinned); 874public static TensorShape CreateForView(nint linearLength, scoped ReadOnlySpan<nint> lengths, scoped ReadOnlySpan<nint> strides, bool pinned) 879public static bool AreLayoutsTheSame(in TensorShape shape1, in TensorShape shape2) 893public static bool AreLengthsTheSame(in TensorShape shape1, in TensorShape shape2) 903public static TensorShape Create(Array? array) 930TensorShape result = new TensorShape( 946public static TensorShape Create(Array? array, scoped ReadOnlySpan<int> start, scoped ReadOnlySpan<nint> lengths, scoped ReadOnlySpan<nint> strides, out nint linearOffset) 1035TensorShape result = new TensorShape(linearLength - computedOffset, lengths, strides, TensorFlags.None); 1057public static TensorShape Create(scoped ReadOnlySpan<nint> lengths, scoped ReadOnlySpan<nint> strides, bool pinned) 1063public static TensorShape Create<T>(T[]? array) 1089public static TensorShape Create<T>(T[]? array, scoped ReadOnlySpan<nint> lengths, scoped ReadOnlySpan<nint> strides, bool pinned = false) 1103public static TensorShape Create<T>(T[]? array, int start, scoped ReadOnlySpan<nint> lengths, scoped ReadOnlySpan<nint> strides, bool pinned = false) 1129public static TensorShape Create<T>(ref readonly T reference, nint linearLength, bool pinned) 1161public static TensorShape Create<T>(ref readonly T reference, nint linearLength, scoped ReadOnlySpan<nint> lengths, scoped ReadOnlySpan<nint> strides, bool pinned) 1182public static unsafe TensorShape Create<T>(T* address, nint linearLength) 1185public static unsafe TensorShape Create<T>(T* address, nint linearLength, scoped ReadOnlySpan<nint> lengths, scoped ReadOnlySpan<nint> strides = default) 1189=> (obj is TensorShape other) && (this == other); 1191public bool Equals(TensorShape other) => (this == other); 1348public TensorShape Slice<TGetOffsetAndLength, T>(ReadOnlySpan<T> state, out nint linearOffset) 1470TensorShape result = new TensorShape(
System\Numerics\Tensors\netcore\TensorSpan_1.cs (22)
29internal readonly TensorShape _shape; 38_shape = TensorShape.Create(array); 55_shape = TensorShape.Create(array, lengths, strides); 67_shape = TensorShape.Create(array, start, lengths, strides); 77_shape = TensorShape.Create(ref reference, span.Length, pinned: false); 89_shape = TensorShape.Create(ref reference, span.Length, lengths, strides, pinned: false); 99_shape = TensorShape.Create(array); 111_shape = TensorShape.Create(array, start, lengths, strides, out nint linearOffset); 121_shape = TensorShape.Create(data, dataLength); 134_shape = TensorShape.Create(data, dataLength, lengths, strides); 140_shape = TensorShape.CreateForView(dataLength, lengths, strides, pinned); 144internal TensorSpan(ref T reference, scoped in TensorShape shape) 153get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNInt, nint>(indexes)); 159get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 301TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForSlice, nint>(startIndexes, out nint linearOffset); 311TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(startIndexes, out nint linearOffset); 321TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNRange, NRange>(ranges, out nint linearOffset); 344nint longestContiguousLength = _shape.GetLongestContiguousLength<TensorShape.GetOffsetAndLengthForNInt, nint>(startIndexes, out nint linearOffset); 360nint longestContiguousLength = _shape.GetLongestContiguousLength<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(startIndexes, out nint linearOffset);