198 references to TensorSpanHelpers
System.Numerics.Tensors (198)
System\Numerics\Tensors\netcore\ReadOnlyTensorSpan.cs (41)
77nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 89strides = strides.IsEmpty ? (ReadOnlySpan<nint>)TensorSpanHelpers.CalculateStrides(lengths, linearLength) : strides; 90TensorSpanHelpers.ValidateStrides(strides, lengths); 91nint maxElements = TensorSpanHelpers.ComputeMaxLinearIndex(strides, lengths); 127nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 129strides = strides.IsEmpty ? (ReadOnlySpan<nint>)TensorSpanHelpers.CalculateStrides(lengths, linearLength) : strides; 130TensorSpanHelpers.ValidateStrides(strides, lengths); 131nint maxElements = TensorSpanHelpers.ComputeMaxLinearIndex(strides, lengths); 158nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 169strides = strides.IsEmpty ? (ReadOnlySpan<nint>)TensorSpanHelpers.CalculateStrides(lengths, linearLength) : strides; 170TensorSpanHelpers.ValidateStrides(strides, lengths); 172nint startOffset = TensorSpanHelpers.ComputeStartOffsetSystemArray(array, start); 173nint maxElements = TensorSpanHelpers.ComputeMaxLinearIndex(strides, lengths); 202nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 213strides = strides.IsEmpty ? (ReadOnlySpan<nint>)TensorSpanHelpers.CalculateStrides(lengths, linearLength) : strides; 214TensorSpanHelpers.ValidateStrides(strides, lengths); 216nint startOffset = TensorSpanHelpers.ComputeStartOffsetSystemArray(array, startIndex); 217nint maxElements = TensorSpanHelpers.ComputeMaxLinearIndex(strides, lengths); 276nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 278strides = strides.IsEmpty ? (ReadOnlySpan<nint>)TensorSpanHelpers.CalculateStrides(lengths, linearLength) : strides; 279TensorSpanHelpers.ValidateStrides(strides, lengths); 280nint maxElements = TensorSpanHelpers.ComputeMaxLinearIndex(strides, lengths); 292nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 314nint index = TensorSpanHelpers.ComputeLinearIndex(indexes, Strides, Lengths); 337nint index = TensorSpanHelpers.ComputeLinearIndex(indexes, Strides, Lengths); 477TensorSpanHelpers.AdjustIndexes(_span.Rank - 1, 1, _curIndexes, _span.Lengths); 551TensorSpanHelpers.Memmove(ref Unsafe.Add(ref destinationSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, destinationSlice.Strides, destinationSlice.Lengths)), ref Unsafe.Add(ref srcSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, srcSlice.Strides, srcSlice.Lengths)), copyLength); 552TensorSpanHelpers.AdjustIndexes(indexToAdjust, 1, curIndexes, tempLengths); 607TensorSpanHelpers.Memmove(ref Unsafe.Add(ref destinationSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, destinationSlice.Strides, destinationSlice.Lengths)), ref Unsafe.Add(ref srcSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, srcSlice.Strides, srcSlice.Lengths)), copyLength); 608TensorSpanHelpers.AdjustIndexes(indexToAdjust, 1, curIndexes, tempLengths); 754TensorSpanHelpers.Memmove(destination.Slice(checked((int)copiedValues)), ref Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths)), Lengths[Rank - 1]); 755TensorSpanHelpers.AdjustIndexes(Rank - 2, 1, curIndexes, _shape.Lengths); 797destination.Slice(checked((int)copiedValues), (int)Lengths[Rank - 1]).Fill(Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths))); 801TensorSpanHelpers.Memmove(destination.Slice(checked((int)copiedValues)), ref Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths)), Lengths[Rank - 1]); 803TensorSpanHelpers.AdjustIndexes(Rank - 2, 1, curIndexes, _shape.Lengths);
System\Numerics\Tensors\netcore\Tensor.cs (9)
69_flattenedLength = TensorSpanHelpers.CalculateTotalLength(_lengths); 70_strides = strides.IsEmpty ? TensorSpanHelpers.CalculateStrides(_lengths, _flattenedLength) : strides.ToArray(); 71TensorSpanHelpers.ValidateStrides(_strides, _lengths); 72nint maxElements = TensorSpanHelpers.ComputeMaxLinearIndex(_strides, _lengths); 97nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 110nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 122nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 135nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 594TensorSpanHelpers.AdjustIndexes(_tensor.Rank - 1, 1, ref _curIndices, _tensor.Lengths);
System\Numerics\Tensors\netcore\Tensor.Factory.cs (5)
27nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 40nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 115nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 152nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 176nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths);
System\Numerics\Tensors\netcore\TensorExtensions.cs (102)
155nint newSize = TensorSpanHelpers.CalculateTotalLength(shape); 198nint newSize = TensorSpanHelpers.CalculateTotalLength(shape); 241nint newSize = TensorSpanHelpers.CalculateTotalLength(lengths); 294totalLength += TensorSpanHelpers.CalculateTotalLength(tensors[i].Lengths); 362totalLength += TensorSpanHelpers.CalculateTotalLength(tensors[i].Lengths); 417srcIndex = TensorSpanHelpers.ComputeLinearIndex(curIndex, tensors[i].Strides, tensors[i].Lengths); 420TensorSpanHelpers.Memmove(dstSpan, srcSpan, copyLength, valuesCopied); 423TensorSpanHelpers.AdjustIndexes(dimension - 1, 1, curIndex, tensors[0].Lengths); 519TensorSpanHelpers.AdjustIndexes(right.Rank - 1, 1, curIndex, right.Lengths); 575TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 621TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 660TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 705TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 744TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 890TensorSpanHelpers.AdjustIndexes(right.Rank - 1, 1, curIndex, right.Lengths); 950TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1010TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1099TensorSpanHelpers.AdjustIndexes(right.Rank - 1, 1, curIndex, right.Lengths); 1159TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1219TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1264TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1303TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1342TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1387TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1426TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1465TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1511TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1550TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1589TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1635TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1674TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1713TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1802TensorSpanHelpers.AdjustIndexes(right.Rank - 1, 1, curIndex, right.Lengths); 1862TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1922TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2011TensorSpanHelpers.AdjustIndexes(right.Rank - 1, 1, curIndex, right.Lengths); 2071TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2131TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2177TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2216TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2255TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2301TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2340TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2379TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2424TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2463TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2502TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2547TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2586TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2625TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2709TensorSpanHelpers.AdjustIndexes(outTensor.Rank - 1, 1, indexes, tensor._lengths); 2759nint tempLinear = TensorSpanHelpers.CalculateTotalLength(arrLengths); 2787strides = TensorSpanHelpers.CalculateStrides(arrLengths); 2827nint tempLinear = TensorSpanHelpers.CalculateTotalLength(arrLengths); 2857strides = TensorSpanHelpers.CalculateStrides(arrLengths); 2898nint tempLinear = TensorSpanHelpers.CalculateTotalLength(arrLengths); 2926strides = TensorSpanHelpers.CalculateStrides(arrLengths); 2942nint newSize = TensorSpanHelpers.CalculateTotalLength(lengths); 2948TensorSpanHelpers.Memmove(ospan, span, tensor._values.Length); 2950TensorSpanHelpers.Memmove(ospan, span, newSize); 2966TensorSpanHelpers.Memmove(ospan, span, tensor._values.Length); 2968TensorSpanHelpers.Memmove(ospan, span, destination._shape._memoryLength); 2982TensorSpanHelpers.Memmove(ospan, span, tensor._shape._memoryLength); 2984TensorSpanHelpers.Memmove(ospan, span, destination._shape._memoryLength); 2998TensorSpanHelpers.Memmove(ospan, span, tensor._shape._memoryLength); 3000TensorSpanHelpers.Memmove(ospan, span, destination._shape._memoryLength); 3098TensorSpanHelpers.Memmove(ref Unsafe.Add(ref destination._reference, TensorSpanHelpers.ComputeLinearIndex(oIndices, tensor.Strides, tensor.Lengths)), ref Unsafe.Add(ref islice._reference, TensorSpanHelpers.ComputeLinearIndex(iIndices, islice.Strides, islice.Lengths)), copyLength); 3099TensorSpanHelpers.AdjustIndexes((int)dimension, 1, oIndices, tensor.Lengths); 3100TensorSpanHelpers.AdjustIndexesDown((int)dimension, 1, iIndices, tensor.Lengths); 3246TensorSpanHelpers.Memmove(ref Unsafe.Add(ref oslice._reference, TensorSpanHelpers.ComputeLinearIndex(oIndices, outputs[0].Strides, outputs[0].Lengths)), ref Unsafe.Add(ref islice._reference, TensorSpanHelpers.ComputeLinearIndex(iIndices, islice.Strides, islice.Lengths)), copyLength); 3247TensorSpanHelpers.AdjustIndexes((int)dimension, 1, oIndices, outputs[i]._lengths); 3248TensorSpanHelpers.AdjustIndexes((int)dimension - 1, 1, iIndices, tensor.Lengths); 3298strides = TensorSpanHelpers.CalculateStrides(lengths); 3314strides = TensorSpanHelpers.CalculateStrides(lengths); 3354strides = TensorSpanHelpers.CalculateStrides(lengths); 3370strides = TensorSpanHelpers.CalculateStrides(lengths); 3410strides = TensorSpanHelpers.CalculateStrides(lengths); 3426strides = TensorSpanHelpers.CalculateStrides(lengths); 3570var sp = new ReadOnlyTensorSpan<T>(ref Unsafe.Add(ref tensor._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, tensor.Strides, tensor.Lengths)), [tensor.Lengths[tensor.Rank - 1]], [1], tensor.Lengths[tensor.Rank - 1]); 3576TensorSpanHelpers.AdjustIndexes(tensor.Rank - 2, 1, curIndexes, tensor.Lengths); 4663lspan = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Add(ref x._reference, TensorSpanHelpers.ComputeLinearIndex(leftIndexes, x.Strides, x.Lengths)), (int)rowLength); 4664rspan = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Add(ref y._reference, TensorSpanHelpers.ComputeLinearIndex(rightIndexes, y.Strides, y.Lengths)), (int)rowLength); 6850nint newLength = TensorSpanHelpers.CalculateTotalLength(newLengths); 6906TensorSpanHelpers.AdjustIndexes(input.Rank - 2, 1, curIndex, input.Lengths); 6958TensorSpanHelpers.AdjustIndexes(input.Rank - 2, 1, curIndex, input.Lengths); 7010TensorSpanHelpers.AdjustIndexes(input.Rank - 2, 1, curIndex, input.Lengths); 7073ospan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref slicedDestination._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, slicedDestination.Strides, slicedDestination.Lengths)), (int)rowLength); 7078TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths); 7086ospan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref slicedDestination._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, slicedDestination.Strides, slicedDestination.Lengths)), (int)rowLength); 7088ispan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedRight._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedRight.Strides, broadcastedRight.Lengths)), (int)rowLength); 7091TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths); 7099ospan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref slicedDestination._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, slicedDestination.Strides, slicedDestination.Lengths)), (int)rowLength); 7101ispan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedLeft._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedLeft.Strides, broadcastedLeft.Lengths)), (int)rowLength); 7104TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths); 7113ospan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref slicedDestination._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, slicedDestination.Strides, slicedDestination.Lengths)), (int)rowLength); 7114ispan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedLeft._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedLeft.Strides, broadcastedLeft.Lengths)), (int)rowLength); 7115rspan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedRight._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedRight.Strides, broadcastedRight.Lengths)), (int)rowLength); 7118TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths);
System\Numerics\Tensors\netcore\TensorShape.cs (1)
62public nint FlattenedLength => TensorSpanHelpers.CalculateTotalLength(Lengths);
System\Numerics\Tensors\netcore\TensorSpan.cs (40)
79nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 91strides = strides.IsEmpty ? (ReadOnlySpan<nint>)TensorSpanHelpers.CalculateStrides(lengths, linearLength) : strides; 92TensorSpanHelpers.ValidateStrides(strides, lengths); 93nint maxElements = TensorSpanHelpers.ComputeMaxLinearIndex(strides, lengths); 129nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 131strides = strides.IsEmpty ? (ReadOnlySpan<nint>)TensorSpanHelpers.CalculateStrides(lengths, linearLength) : strides; 132TensorSpanHelpers.ValidateStrides(strides, lengths); 134nint maxElements = TensorSpanHelpers.ComputeMaxLinearIndex(strides, lengths); 161nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 173strides = strides.IsEmpty ? (ReadOnlySpan<nint>)TensorSpanHelpers.CalculateStrides(lengths, linearLength) : strides; 174TensorSpanHelpers.ValidateStrides(strides, lengths); 176nint startOffset = TensorSpanHelpers.ComputeStartOffsetSystemArray(array, start); 177nint maxElements = TensorSpanHelpers.ComputeMaxLinearIndex(strides, lengths); 206nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 207strides = strides.IsEmpty ? (ReadOnlySpan<nint>)TensorSpanHelpers.CalculateStrides(lengths, linearLength) : strides; 208TensorSpanHelpers.ValidateStrides(strides, lengths); 219nint startOffset = TensorSpanHelpers.ComputeStartOffsetSystemArray(array, startIndex); 220nint maxElements = TensorSpanHelpers.ComputeMaxLinearIndex(strides, lengths); 279nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 281strides = strides.IsEmpty ? (ReadOnlySpan<nint>)TensorSpanHelpers.CalculateStrides(lengths, linearLength) : strides; 282TensorSpanHelpers.ValidateStrides(strides, lengths); 284nint maxElements = TensorSpanHelpers.ComputeMaxLinearIndex(strides, lengths); 296nint linearLength = TensorSpanHelpers.CalculateTotalLength(lengths); 318nint index = TensorSpanHelpers.ComputeLinearIndex(indexes, Strides, Lengths); 343nint index = TensorSpanHelpers.ComputeLinearIndex(indexes, Strides, Lengths); 473TensorSpanHelpers.AdjustIndexes(_span.Rank - 1, 1, _curIndexes, _span.Lengths); 525TensorSpanHelpers.Clear(ref Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths)), (nuint)Lengths[Rank - 1]); 526TensorSpanHelpers.AdjustIndexes(Rank - 2, 1, curIndexes, _shape.Lengths); 582TensorSpanHelpers.Memmove(ref Unsafe.Add(ref destinationSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, destinationSlice.Strides, destinationSlice.Lengths)), ref Unsafe.Add(ref srcSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, srcSlice.Strides, srcSlice.Lengths)), copyLength); 583TensorSpanHelpers.AdjustIndexes(indexToAdjust, 1, curIndexes, tempLengths); 636TensorSpanHelpers.Memmove(ref Unsafe.Add(ref destinationSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, destinationSlice.Strides, destinationSlice.Lengths)), ref Unsafe.Add(ref srcSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, srcSlice.Strides, srcSlice.Lengths)), copyLength); 637TensorSpanHelpers.AdjustIndexes(indexToAdjust, 1, curIndexes, tempLengths); 809TensorSpanHelpers.Memmove(destination.Slice(checked((int)copiedValues)), ref Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths)), Lengths[Rank - 1]); 810TensorSpanHelpers.AdjustIndexes(Rank - 2, 1, curIndexes, _shape.Lengths);