256 references to Rank
System.Numerics.Tensors (256)
System\Numerics\Tensors\netcore\ReadOnlyTensorSpan.cs (37)
328if (indexes.Length != Rank) 351if (indexes.Length != Rank) 374if (ranges.Length != Rank) 421left.Rank == right.Rank && 486_curIndexes = new nint[_span.Rank]; 487_curIndexes[_span.Rank - 1] = -1; 494TensorSpanHelpers.AdjustIndexes(_span.Rank - 1, 1, _curIndexes, _span.Lengths); 545if (Rank > TensorShape.MaxInlineRank) 564int indexToAdjust = srcSlice.Strides[^1] == 1 && TensorHelpers.IsContiguousAndDense(srcSlice) ? srcSlice.Rank - 2 : srcSlice.Rank - 1; 601if (Rank > TensorShape.MaxInlineRank) 620int indexToAdjust = srcSlice.Strides[^1] == 1 && TensorHelpers.IsContiguousAndDense(srcSlice) ? srcSlice.Rank - 2 : srcSlice.Rank - 1; 696if (Rank > TensorShape.MaxInlineRank) 698lengthsArray = ArrayPool<nint>.Shared.Rent(Rank); 699lengths = lengthsArray.AsSpan(0, Rank); 701offsetsArray = ArrayPool<nint>.Shared.Rent(Rank); 702offsets = offsetsArray.AsSpan(0, Rank); 706lengths = stackalloc nint[Rank]; 707offsets = stackalloc nint[Rank]; 756if (Rank > TensorShape.MaxInlineRank) 758curIndexesArray = ArrayPool<nint>.Shared.Rent(Rank); 759curIndexes = curIndexesArray.AsSpan(0, Rank); 764curIndexes = stackalloc nint[Rank]; 771TensorSpanHelpers.Memmove(destination.Slice(checked((int)copiedValues)), ref Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths)), Lengths[Rank - 1]); 772TensorSpanHelpers.AdjustIndexes(Rank - 2, 1, curIndexes, _shape.Lengths); 773copiedValues += Lengths[Rank - 1]; 797if (Rank > TensorShape.MaxInlineRank) 799curIndexesArray = ArrayPool<nint>.Shared.Rent(Rank); 800curIndexes = curIndexesArray.AsSpan(0, Rank); 805curIndexes = stackalloc nint[Rank]; 812if (Strides[Rank - 1] == 0) 814destination.Slice(checked((int)copiedValues), (int)Lengths[Rank - 1]).Fill(Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths))); 818TensorSpanHelpers.Memmove(destination.Slice(checked((int)copiedValues)), ref Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths)), Lengths[Rank - 1]); 820TensorSpanHelpers.AdjustIndexes(Rank - 2, 1, curIndexes, _shape.Lengths); 821copiedValues += Lengths[Rank - 1];
System\Numerics\Tensors\netcore\TensorExtensions.cs (215)
559if (x.Rank > TensorShape.MaxInlineRank) 561curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 562curIndex = curIndexArray.AsSpan(0, x.Rank); 567curIndex = stackalloc nint[x.Rank]; 574TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 604if (broadcastedLeft.Rank > TensorShape.MaxInlineRank) 606curIndexArray = ArrayPool<nint>.Shared.Rent(broadcastedRight.Rank); 607curIndex = curIndexArray.AsSpan(0, broadcastedRight.Rank); 612curIndex = stackalloc nint[broadcastedRight.Rank]; 620TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 643if (x.Rank > TensorShape.MaxInlineRank) 645curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 646curIndex = curIndexArray.AsSpan(0, x.Rank); 651curIndex = stackalloc nint[x.Rank]; 659TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 688if (broadcastedRight.Rank > TensorShape.MaxInlineRank) 691curIndex = curIndexArray.AsSpan(0, broadcastedRight.Rank); 704TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 727if (x.Rank > TensorShape.MaxInlineRank) 729curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 730curIndex = curIndexArray.AsSpan(0, x.Rank); 735curIndex = stackalloc nint[x.Rank]; 743TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 790if (values.Rank != 1) 934if (x.Rank > TensorShape.MaxInlineRank) 936curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 937curIndex = curIndexArray.AsSpan(0, x.Rank); 942curIndex = stackalloc nint[x.Rank]; 949TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 994if (y.Rank > TensorShape.MaxInlineRank) 996curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 997curIndex = curIndexArray.AsSpan(0, y.Rank); 1002curIndex = stackalloc nint[y.Rank]; 1009TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1143if (x.Rank > TensorShape.MaxInlineRank) 1145curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 1146curIndex = curIndexArray.AsSpan(0, x.Rank); 1151curIndex = stackalloc nint[x.Rank]; 1158TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1203if (y.Rank > TensorShape.MaxInlineRank) 1205curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 1206curIndex = curIndexArray.AsSpan(0, y.Rank); 1211curIndex = stackalloc nint[y.Rank]; 1218TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1247if (broadcastedRight.Rank > TensorShape.MaxInlineRank) 1250curIndex = curIndexArray.AsSpan(0, broadcastedRight.Rank); 1263TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1286if (x.Rank > TensorShape.MaxInlineRank) 1288curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 1289curIndex = curIndexArray.AsSpan(0, x.Rank); 1294curIndex = stackalloc nint[x.Rank]; 1302TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1325if (y.Rank > TensorShape.MaxInlineRank) 1327curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 1328curIndex = curIndexArray.AsSpan(0, y.Rank); 1333curIndex = stackalloc nint[y.Rank]; 1341TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1370if (broadcastedRight.Rank > TensorShape.MaxInlineRank) 1373curIndex = curIndexArray.AsSpan(0, broadcastedRight.Rank); 1386TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1409if (x.Rank > TensorShape.MaxInlineRank) 1411curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 1412curIndex = curIndexArray.AsSpan(0, x.Rank); 1417curIndex = stackalloc nint[x.Rank]; 1425TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1448if (y.Rank > TensorShape.MaxInlineRank) 1450curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 1451curIndex = curIndexArray.AsSpan(0, y.Rank); 1456curIndex = stackalloc nint[y.Rank]; 1464TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1494if (broadcastedLeft.Rank > TensorShape.MaxInlineRank) 1496curIndexArray = ArrayPool<nint>.Shared.Rent(broadcastedRight.Rank); 1497curIndex = curIndexArray.AsSpan(0, broadcastedRight.Rank); 1502curIndex = stackalloc nint[broadcastedRight.Rank]; 1510TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1533if (x.Rank > TensorShape.MaxInlineRank) 1535curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 1536curIndex = curIndexArray.AsSpan(0, x.Rank); 1541curIndex = stackalloc nint[x.Rank]; 1549TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1572if (y.Rank > TensorShape.MaxInlineRank) 1574curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 1575curIndex = curIndexArray.AsSpan(0, y.Rank); 1580curIndex = stackalloc nint[y.Rank]; 1588TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1618if (broadcastedLeft.Rank > TensorShape.MaxInlineRank) 1620curIndexArray = ArrayPool<nint>.Shared.Rent(broadcastedRight.Rank); 1621curIndex = curIndexArray.AsSpan(0, broadcastedRight.Rank); 1626curIndex = stackalloc nint[broadcastedRight.Rank]; 1634TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1657if (x.Rank > TensorShape.MaxInlineRank) 1659curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 1660curIndex = curIndexArray.AsSpan(0, x.Rank); 1665curIndex = stackalloc nint[x.Rank]; 1673TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1696if (y.Rank > TensorShape.MaxInlineRank) 1698curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 1699curIndex = curIndexArray.AsSpan(0, y.Rank); 1704curIndex = stackalloc nint[y.Rank]; 1712TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1846if (x.Rank > TensorShape.MaxInlineRank) 1848curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 1849curIndex = curIndexArray.AsSpan(0, x.Rank); 1854curIndex = stackalloc nint[x.Rank]; 1861TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1906if (y.Rank > TensorShape.MaxInlineRank) 1908curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 1909curIndex = curIndexArray.AsSpan(0, y.Rank); 1914curIndex = stackalloc nint[y.Rank]; 1921TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2055if (x.Rank > TensorShape.MaxInlineRank) 2057curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 2058curIndex = curIndexArray.AsSpan(0, x.Rank); 2063curIndex = stackalloc nint[x.Rank]; 2070TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2115if (y.Rank > TensorShape.MaxInlineRank) 2117curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 2118curIndex = curIndexArray.AsSpan(0, y.Rank); 2123curIndex = stackalloc nint[y.Rank]; 2130TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2160if (broadcastedRight.Rank > TensorShape.MaxInlineRank) 2163curIndex = curIndexArray.AsSpan(0, broadcastedRight.Rank); 2176TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2199if (x.Rank > TensorShape.MaxInlineRank) 2201curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 2202curIndex = curIndexArray.AsSpan(0, x.Rank); 2207curIndex = stackalloc nint[x.Rank]; 2215TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2238if (y.Rank > TensorShape.MaxInlineRank) 2240curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 2241curIndex = curIndexArray.AsSpan(0, y.Rank); 2246curIndex = stackalloc nint[y.Rank]; 2254TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2284if (broadcastedRight.Rank > TensorShape.MaxInlineRank) 2287curIndex = curIndexArray.AsSpan(0, broadcastedRight.Rank); 2300TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2323if (x.Rank > TensorShape.MaxInlineRank) 2325curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 2326curIndex = curIndexArray.AsSpan(0, x.Rank); 2331curIndex = stackalloc nint[x.Rank]; 2339TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2362if (y.Rank > TensorShape.MaxInlineRank) 2364curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 2365curIndex = curIndexArray.AsSpan(0, y.Rank); 2370curIndex = stackalloc nint[y.Rank]; 2378TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2407if (broadcastedRight.Rank > TensorShape.MaxInlineRank) 2410curIndex = curIndexArray.AsSpan(0, broadcastedRight.Rank); 2423TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2446if (x.Rank > TensorShape.MaxInlineRank) 2448curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 2449curIndex = curIndexArray.AsSpan(0, x.Rank); 2454curIndex = stackalloc nint[x.Rank]; 2462TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2485if (y.Rank > TensorShape.MaxInlineRank) 2487curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 2488curIndex = curIndexArray.AsSpan(0, y.Rank); 2493curIndex = stackalloc nint[y.Rank]; 2501TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2530if (broadcastedRight.Rank > TensorShape.MaxInlineRank) 2533curIndex = curIndexArray.AsSpan(0, broadcastedRight.Rank); 2546TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2569if (x.Rank > TensorShape.MaxInlineRank) 2571curIndexArray = ArrayPool<nint>.Shared.Rent(x.Rank); 2572curIndex = curIndexArray.AsSpan(0, x.Rank); 2577curIndex = stackalloc nint[x.Rank]; 2585TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2608if (y.Rank > TensorShape.MaxInlineRank) 2610curIndexArray = ArrayPool<nint>.Shared.Rent(y.Rank); 2611curIndex = curIndexArray.AsSpan(0, y.Rank); 2616curIndex = stackalloc nint[y.Rank]; 2624TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2910if (lengthOffset < tensor.Rank && arrLengths[i] == tensor.Lengths[lengthOffset]) 2914if (lengthOffset == tensor.Rank) 3073if (tensor.Rank > 6) 3075oIndicesArray = ArrayPool<nint>.Shared.Rent(tensor.Rank); 3076oIndices = oIndicesArray.AsSpan(0, tensor.Rank); 3079iIndicesArray = ArrayPool<nint>.Shared.Rent(tensor.Rank); 3080iIndices = iIndicesArray.AsSpan(0, tensor.Rank); 3086oIndices = stackalloc nint[tensor.Rank]; 3088iIndices = stackalloc nint[tensor.Rank]; 3213if (tensor.Rank > 6) 3215oIndicesArray = ArrayPool<nint>.Shared.Rent(tensor.Rank); 3216oIndices = oIndicesArray.AsSpan(0, tensor.Rank); 3219iIndicesArray = ArrayPool<nint>.Shared.Rent(tensor.Rank); 3220iIndices = iIndicesArray.AsSpan(0, tensor.Rank); 3226oIndices = stackalloc nint[tensor.Rank]; 3228iIndices = stackalloc nint[tensor.Rank]; 3392if (dimension >= tensor.Rank) 3563if (maximumLengths.Length != tensor.Rank) 3568if (tensor.Rank > 6) 3570curIndexesArray = ArrayPool<nint>.Shared.Rent(tensor.Rank); 3571curIndexes = curIndexesArray.AsSpan(0, tensor.Rank); 3577curIndexes = stackalloc nint[tensor.Rank]; 3582T[] values = new T[tensor.Lengths[tensor.Rank - 1]]; 3585var 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]); 3591TensorSpanHelpers.AdjustIndexes(tensor.Rank - 2, 1, curIndexes, tensor.Lengths); 3592copiedValues += tensor.Lengths[tensor.Rank - 1]; 3758dimension = tensor.Rank - dimension; 3770if (dimension == tensor.Rank) 4660if (x.Rank != 2) 4663if (y.Rank != 2) 4690if (x.Rank != 2) 4693if (y.Rank != 2) 6944curIndex = curIndexArray.AsSpan(0, input.Rank); 6962TensorSpanHelpers.AdjustIndexes(input.Rank - 2, 1, curIndex, input.Lengths); 6996curIndex = curIndexArray.AsSpan(0, input.Rank); 7014TensorSpanHelpers.AdjustIndexes(input.Rank - 2, 1, curIndex, input.Lengths); 7048curIndex = curIndexArray.AsSpan(0, input.Rank); 7066TensorSpanHelpers.AdjustIndexes(input.Rank - 2, 1, curIndex, input.Lengths); 7134TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths); 7147TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths); 7160TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths); 7174TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths);
System\Numerics\Tensors\netcore\TensorSpan.cs (4)
593int indexToAdjust = srcSlice.Strides[^1] == 1 && TensorHelpers.IsContiguousAndDense(srcSlice) ? srcSlice.Rank - 2 : srcSlice.Rank - 1; 647int indexToAdjust = srcSlice.Strides[^1] == 1 && TensorHelpers.IsContiguousAndDense(srcSlice) ? srcSlice.Rank - 2 : srcSlice.Rank - 1;