445 references to Lengths
System.Numerics.Tensors (445)
System\Numerics\Tensors\netcore\ReadOnlyTensorSpan.cs (24)
331nint index = TensorSpanHelpers.ComputeLinearIndex(indexes, Strides, Lengths); 354nint index = TensorSpanHelpers.ComputeLinearIndex(indexes, Strides, Lengths); 401public int Rank => Lengths.Length; 494TensorSpanHelpers.AdjustIndexes(_span.Rank - 1, 1, _curIndexes, _span.Lengths); 540if (TensorHelpers.IsBroadcastableTo(Lengths, destination.Lengths)) 559nint[] tempLengths = Tensor.GetSmallestBroadcastableLengths(Lengths, destination.Lengths); 563nint copyLength = srcSlice.Strides[^1] == 1 && TensorHelpers.IsContiguousAndDense(srcSlice) ? srcSlice.Lengths[^1] : 1; 568TensorSpanHelpers.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); 596if (TensorHelpers.IsBroadcastableTo(Lengths, destination.Lengths)) 615nint[] tempLengths = Tensor.GetSmallestBroadcastableLengths(Lengths, destination.Lengths); 619nint copyLength = srcSlice.Strides[^1] == 1 && TensorHelpers.IsContiguousAndDense(srcSlice) ? srcSlice.Lengths[^1] : 1; 624TensorSpanHelpers.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); 660ranges[i] = new NRange(checked((int)indexes[i].GetOffset(Lengths[i])), Lengths[i]); 688if (ranges.Length != Lengths.Length) 717(offsets[i], lengths[i]) = ranges[i].GetOffsetAndLength(Lengths[i]); 771TensorSpanHelpers.Memmove(destination.Slice(checked((int)copiedValues)), ref Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths)), Lengths[Rank - 1]); 773copiedValues += Lengths[Rank - 1]; 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]); 821copiedValues += Lengths[Rank - 1];
System\Numerics\Tensors\netcore\TensorExtensions.cs (413)
56return Broadcast(source, lengthsSource.Lengths); 68nint[] newSize = Tensor.GetSmallestBroadcastableLengths(source.Lengths, lengths); 71Tensor<T> output = Tensor.CreateUninitialized<T>(intermediate.Lengths); 115nint[] newSize = Tensor.GetSmallestBroadcastableLengths(source.Lengths, destination.Lengths); 177if (input.Lengths.SequenceEqual(shape)) 180if (!TensorHelpers.IsBroadcastableTo(input.Lengths, shape)) 188nint[] intermediateShape = TensorHelpers.GetIntermediateShape(input.Lengths, shape.Length); 445result = Tensor.Create<bool>(x.Lengths, false); 449nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 472if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, x.Lengths)) 479nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 523Tensor<bool> result = Tensor.Create<bool>(x.Lengths, false); 539if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, x.Lengths)) 560TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 583nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 606TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 645TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 667nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 676curIndexArray = ArrayPool<nint>.Shared.Rent(broadcastedRight.Lengths.Length); 682curIndex = stackalloc nint[broadcastedRight.Lengths.Length]; 690TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 729TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 748if (filter.Lengths.Length != tensor.Lengths.Length) 774if (filter.Lengths.Length != tensor.Lengths.Length) 813result = Tensor.Create<bool>(x.Lengths, false); 817nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 843if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, x.Lengths)) 850nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 896Tensor<bool> result = Tensor.Create<bool>(x.Lengths, false); 914if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, x.Lengths)) 935TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 956Tensor<bool> result = Tensor.Create<bool>(y.Lengths, false); 974if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, y.Lengths)) 995TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1022result = Tensor.Create<bool>(x.Lengths, false); 1026nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 1052if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, x.Lengths)) 1059nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 1105Tensor<bool> result = Tensor.Create<bool>(x.Lengths, false); 1123if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, x.Lengths)) 1144TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1165Tensor<bool> result = Tensor.Create<bool>(y.Lengths, false); 1183if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, y.Lengths)) 1204TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1226nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 1235curIndexArray = ArrayPool<nint>.Shared.Rent(broadcastedRight.Lengths.Length); 1241curIndex = stackalloc nint[broadcastedRight.Lengths.Length]; 1249TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1288TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1327TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1349nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 1358curIndexArray = ArrayPool<nint>.Shared.Rent(broadcastedRight.Lengths.Length); 1364curIndex = stackalloc nint[broadcastedRight.Lengths.Length]; 1372TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1411TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1450TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1473nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 1496TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1535TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1574TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1597nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 1620TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 1659TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1698TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1725result = Tensor.Create<bool>(x.Lengths, false); 1729nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 1755if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, x.Lengths)) 1762nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 1808Tensor<bool> result = Tensor.Create<bool>(x.Lengths, false); 1826if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, x.Lengths)) 1847TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 1868Tensor<bool> result = Tensor.Create<bool>(y.Lengths, false); 1886if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, y.Lengths)) 1907TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 1934result = Tensor.Create<bool>(x.Lengths, false); 1938nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 1964if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, x.Lengths)) 1971nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 2017Tensor<bool> result = Tensor.Create<bool>(x.Lengths, false); 2035if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, x.Lengths)) 2056TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2077Tensor<bool> result = Tensor.Create<bool>(y.Lengths, false); 2095if (!TensorHelpers.AreLengthsTheSame(destination.Lengths, y.Lengths)) 2116TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2139nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 2148curIndexArray = ArrayPool<nint>.Shared.Rent(broadcastedRight.Lengths.Length); 2154curIndex = stackalloc nint[broadcastedRight.Lengths.Length]; 2162TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2201TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2240TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2263nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 2272curIndexArray = ArrayPool<nint>.Shared.Rent(broadcastedRight.Lengths.Length); 2278curIndex = stackalloc nint[broadcastedRight.Lengths.Length]; 2286TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2325TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2364TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2386nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 2395curIndexArray = ArrayPool<nint>.Shared.Rent(broadcastedRight.Lengths.Length); 2401curIndex = stackalloc nint[broadcastedRight.Lengths.Length]; 2409TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2448TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2487TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2509nint[] newSize = Tensor.GetSmallestBroadcastableLengths(x.Lengths, y.Lengths); 2518curIndexArray = ArrayPool<nint>.Shared.Rent(broadcastedRight.Lengths.Length); 2524curIndex = stackalloc nint[broadcastedRight.Lengths.Length]; 2532TensorSpanHelpers.AdjustIndexes(broadcastedRight.Rank - 1, 1, curIndex, broadcastedRight.Lengths); 2571TensorSpanHelpers.AdjustIndexes(x.Rank - 1, 1, curIndex, x.Lengths); 2610TensorSpanHelpers.AdjustIndexes(y.Rank - 1, 1, curIndex, y.Lengths); 2857if (tensor.Lengths.SequenceEqual(lengths)) 2896if (lengthOffset < tensor.Rank && arrLengths[i] == tensor.Lengths[lengthOffset]) 2903origStrides.Insert(i, tensor.Strides[i] * tensor.Lengths[i]); 2996Tensor<T> output = Tensor.Create<T>(tensor.Lengths); 3010Tensor<T> output = Tensor.Create<T>(tensor.Lengths); 3049for (nint i = dimension; i < tensor.Lengths.Length; i++) 3051copyLength *= tensor.Lengths[(int)i]; 3053copyLength /= tensor.Lengths[(int)dimension]; 3077iIndices[(int)dimension] = tensor.Lengths[(int)dimension] - 1; 3079ReadOnlyTensorSpan<T> islice = tensor.Slice(tensor.Lengths); 3083TensorSpanHelpers.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); 3084TensorSpanHelpers.AdjustIndexes((int)dimension, 1, oIndices, tensor.Lengths); 3085TensorSpanHelpers.AdjustIndexesDown((int)dimension, 1, iIndices, tensor.Lengths); 3109&& tensor.Lengths.SequenceEqual(other.Lengths) 3121&& tensor.Lengths.SequenceEqual(other.Lengths) 3151if (!TensorHelpers.IsBroadcastableTo(values.Lengths, tensor.Lengths)) 3161if (!TensorHelpers.IsBroadcastableTo(values.Lengths, srcSpan.Lengths)) 3180if (tensor.Lengths[(int)dimension] % splitCount != 0) 3187for (nint i = dimension; i < tensor.Lengths.Length; i++) 3189copyLength *= tensor.Lengths[(int)i]; 3192nint[] newShape = tensor.Lengths.ToArray(); 3225ReadOnlyTensorSpan<T> islice = tensor.Slice(tensor.Lengths); 3231TensorSpanHelpers.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); 3233TensorSpanHelpers.AdjustIndexes((int)dimension - 1, 1, iIndices, tensor.Lengths); 3387for (int i = 0; i < tensor.Lengths.Length; i++) 3389if (tensor.Lengths[i] != 1) 3391tempLengths.Add(tensor.Lengths[i]); 3399if (tensor.Lengths[dimension] != 1) 3403for (int i = 0; i < tensor.Lengths.Length; i++) 3407tempLengths.Add(tensor.Lengths[i]); 3538T[] values = new T[tensor.Lengths[tensor.Rank - 1]]; 3541var 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]); 3547TensorSpanHelpers.AdjustIndexes(tensor.Rank - 2, 1, curIndexes, tensor.Lengths); 3548copiedValues += tensor.Lengths[tensor.Rank - 1]; 3617if (!TensorHelpers.IsBroadcastableTo(tensor.Lengths, destination.Lengths)) 3620nint[] newSize = Tensor.GetSmallestBroadcastableLengths(tensor.Lengths, destination.Lengths); 3711if (dimension > tensor.Lengths.Length) 3716Span<nint> lengths = tensor.Lengths.Length + 1 <= TensorShape.MaxInlineRank ? 3717stackalloc nint[tensor.Lengths.Length + 1] : 3718new nint[tensor.Lengths.Length + 1]; 3719tensor.Lengths.Slice(0, dimension).CopyTo(lengths); 3720tensor.Lengths.Slice(dimension).CopyTo(lengths.Slice(dimension + 1)); 3735strides[dimension] = tensor.Strides[dimension] * tensor.Lengths[dimension]; 3751Tensor<T> output = Tensor.Create<T>(x.Lengths); 3776Tensor<T> output = Tensor.Create<T>(x.Lengths); 3801Tensor<T> output = Tensor.Create<T>(x.Lengths); 3826Tensor<T> output = Tensor.Create<T>(x.Lengths); 3853if (x.Lengths.SequenceEqual(y.Lengths)) 3855output = Tensor.Create<T>(x.Lengths); 3859output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 3874Tensor<T> output = Tensor.Create<T>(x.Lengths); 3912Tensor<T> output = Tensor.Create<T>(x.Lengths); 3937Tensor<T> output = Tensor.Create<T>(x.Lengths); 3962Tensor<T> output = Tensor.Create<T>(x.Lengths); 3987Tensor<T> output = Tensor.Create<T>(x.Lengths); 4014if (x.Lengths.SequenceEqual(y.Lengths)) 4016output = Tensor.Create<T>(x.Lengths); 4020output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 4047Tensor<T> output = Tensor.Create<T>(x.Lengths); 4073Tensor<T> output = Tensor.Create<T>(y.Lengths); 4102if (x.Lengths.SequenceEqual(y.Lengths)) 4104output = Tensor.Create<T>(x.Lengths); 4108output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 4135Tensor<T> output = Tensor.Create<T>(x.Lengths); 4161Tensor<T> output = Tensor.Create<T>(y.Lengths); 4189Tensor<T> output = Tensor.Create<T>(x.Lengths); 4214Tensor<T> output = Tensor.Create<T>(x.Lengths); 4254if (x.Lengths.SequenceEqual(y.Lengths)) 4256output = Tensor.Create<T>(x.Lengths); 4260output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 4287Tensor<T> output = Tensor.Create<T>(x.Lengths); 4316if (x.Lengths.SequenceEqual(y.Lengths)) 4318output = Tensor.Create<T>(x.Lengths); 4322output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 4349Tensor<T> output = Tensor.Create<T>(x.Lengths); 4376Tensor<T> output = Tensor.Create<T>(x.Lengths); 4401Tensor<T> output = Tensor.Create<T>(x.Lengths); 4428Tensor<TTo> output = Tensor.Create<TTo>(source.Lengths); 4458Tensor<TTo> output = Tensor.Create<TTo>(source.Lengths); 4488Tensor<TTo> output = Tensor.Create<TTo>(source.Lengths); 4517Tensor<T> output = Create<T>(x.Lengths); 4532if (x.Lengths.SequenceEqual(sign.Lengths)) 4534output = Tensor.Create<T>(x.Lengths); 4538output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, sign.Lengths)); 4578Tensor<T> output = Tensor.Create<T>(x.Lengths); 4603Tensor<T> output = Tensor.Create<T>(x.Lengths); 4635if (x.Lengths[1] != y.Lengths[1]) 4636ThrowHelper.ThrowArgument_IncompatibleDimensions(x.Lengths[1], y.Lengths[1]); 4638nint dim1 = x.Lengths[0]; 4639nint dim2 = y.Lengths[0]; 4665if (x.Lengths[1] != y.Lengths[1]) 4666ThrowHelper.ThrowArgument_IncompatibleDimensions(x.Lengths[1], y.Lengths[1]); 4668nint dim1 = x.Lengths[0]; 4669nint dim2 = y.Lengths[0]; 4672ThrowHelper.ThrowArgument_IncompatibleDimensions(x.Lengths[1], y.Lengths[1]); 4683int rowLength = (int)x.Lengths[1]; 4688lspan = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Add(ref x._reference, TensorSpanHelpers.ComputeLinearIndex(leftIndexes, x.Strides, x.Lengths)), (int)rowLength); 4689rspan = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Add(ref y._reference, TensorSpanHelpers.ComputeLinearIndex(rightIndexes, y.Strides, y.Lengths)), (int)rowLength); 4720Tensor<T> output = Tensor.Create<T>(x.Lengths); 4755Tensor<T> output = Tensor.Create<T>(x.Lengths); 4794Tensor<T> output = Create<T>(x.Lengths); 4807Tensor<T> output = Tensor.Create<T>(y.Lengths); 4822if (x.Lengths.SequenceEqual(y.Lengths)) 4824output = Tensor.Create<T>(x.Lengths); 4828output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 4894Tensor<T> output = Tensor.Create<T>(x.Lengths); 4919Tensor<T> output = Tensor.Create<T>(x.Lengths); 4942Tensor<T> output = Tensor.Create<T>(x.Lengths); 4963Tensor<T> output = Tensor.Create<T>(x.Lengths); 4984Tensor<T> output = Tensor.Create<T>(x.Lengths); 5005Tensor<T> output = Tensor.Create<T>(x.Lengths); 5026Tensor<T> output = Tensor.Create<T>(x.Lengths); 5052if (x.Lengths.SequenceEqual(y.Lengths)) 5054output = Tensor.Create<T>(x.Lengths); 5058output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 5088if (x.Lengths.SequenceEqual(y.Lengths)) 5090output = Tensor.Create<T>(x.Lengths); 5094output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 5118Tensor<T> output = Tensor.Create<T>(x.Lengths); 5140Tensor<T> output = Tensor.Create<T>(y.Lengths); 5163Tensor<int> output = Tensor.Create<int>(x.Lengths, x.Strides); 5232Tensor<T> output = Tensor.Create<T>(x.Lengths); 5257Tensor<T> output = Tensor.Create<T>(x.Lengths); 5280if (x.Lengths.SequenceEqual(y.Lengths)) 5282output = Tensor.Create<T>(x.Lengths); 5286output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 5309Tensor<T> output = Tensor.Create<T>(x.Lengths); 5334Tensor<T> output = Tensor.Create<T>(x.Lengths); 5359Tensor<T> output = Tensor.Create<T>(x.Lengths); 5384Tensor<T> output = Tensor.Create<T>(x.Lengths); 5409Tensor<T> output = Tensor.Create<T>(x.Lengths); 5434Tensor<T> output = Tensor.Create<T>(x.Lengths); 5467if (x.Lengths.SequenceEqual(y.Lengths)) 5469output = Tensor.Create<T>(x.Lengths); 5473output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 5496Tensor<T> output = Tensor.Create<T>(x.Lengths); 5528if (x.Lengths.SequenceEqual(y.Lengths)) 5530output = Tensor.Create<T>(x.Lengths); 5534output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 5557Tensor<T> output = Tensor.Create<T>(x.Lengths); 5589if (x.Lengths.SequenceEqual(y.Lengths)) 5591output = Tensor.Create<T>(x.Lengths); 5595output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 5618Tensor<T> output = Tensor.Create<T>(x.Lengths); 5650if (x.Lengths.SequenceEqual(y.Lengths)) 5652output = Tensor.Create<T>(x.Lengths); 5656output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 5679Tensor<T> output = Tensor.Create<T>(x.Lengths); 5711if (x.Lengths.SequenceEqual(y.Lengths)) 5713output = Tensor.Create<T>(x.Lengths); 5717output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 5740Tensor<T> output = Tensor.Create<T>(x.Lengths); 5772if (x.Lengths.SequenceEqual(y.Lengths)) 5774output = Tensor.Create<T>(x.Lengths); 5778output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 5801Tensor<T> output = Tensor.Create<T>(x.Lengths); 5833if (x.Lengths.SequenceEqual(y.Lengths)) 5835output = Tensor.Create<T>(x.Lengths); 5839output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 5862Tensor<T> output = Tensor.Create<T>(x.Lengths); 5894if (x.Lengths.SequenceEqual(y.Lengths)) 5896output = Tensor.Create<T>(x.Lengths); 5900output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 5923Tensor<T> output = Tensor.Create<T>(x.Lengths); 5948Tensor<T> output = Tensor.Create<T>(x.Lengths); 5963if (x.Lengths.SequenceEqual(y.Lengths)) 5965output = Tensor.Create<T>(x.Lengths); 5969output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 6011Tensor<T> output = Tensor.Create<T>(x.Lengths); 6044Tensor<T> output = Tensor.Create<T>(x.Lengths); 6065Tensor<T> output = Tensor.Create<T>(x.Lengths); 6088if (x.Lengths.SequenceEqual(y.Lengths)) 6090output = Tensor.Create<T>(x.Lengths); 6094output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 6117Tensor<T> output = Tensor.Create<T>(x.Lengths); 6139Tensor<T> output = Tensor.Create<T>(y.Lengths); 6172Tensor<T> output = Tensor.Create<T>(x.Lengths); 6193Tensor<T> output = Tensor.Create<T>(x.Lengths); 6215Tensor<T> output = Tensor.Create<T>(x.Lengths); 6245Tensor<T> output = Tensor.Create<T>(x.Lengths); 6276Tensor<T> output = Tensor.Create<T>(x.Lengths); 6305Tensor<T> output = Tensor.Create<T>(x.Lengths); 6326Tensor<T> output = Tensor.Create<T>(x.Lengths); 6354Tensor<T> output = Tensor.Create<T>(x.Lengths); 6381Tensor<T> output = Tensor.Create<T>(x.Lengths); 6409Tensor<T> output = Tensor.Create<T>(x.Lengths); 6432Tensor<T> output = Tensor.Create<T>(x.Lengths); 6455Tensor<T> output = Tensor.Create<T>(x.Lengths); 6476Tensor<T> output = Tensor.Create<T>(x.Lengths); 6497Tensor<T> output = Tensor.Create<T>(x.Lengths); 6520Tensor<T> output = Tensor.Create<T>(x.Lengths); 6559Tensor<T> output = Create<T>(x.Lengths); 6572Tensor<T> output = Create<T>(y.Lengths); 6586if (x.Lengths.SequenceEqual(y.Lengths)) 6588output = Tensor.Create<T>(x.Lengths); 6592output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 6668Tensor<T> output = Tensor.Create<T>(x.Lengths); 6689Tensor<T> output = Tensor.Create<T>(x.Lengths); 6710Tensor<T> output = Tensor.Create<T>(x.Lengths); 6731Tensor<T> output = Tensor.Create<T>(x.Lengths); 6752Tensor<T> output = Tensor.Create<T>(x.Lengths); 6775if (x.Lengths.SequenceEqual(y.Lengths)) 6777output = Tensor.Create<T>(x.Lengths); 6781output = Tensor.Create<T>(GetSmallestBroadcastableLengths(x.Lengths, y.Lengths)); 6806Tensor<T> output = Tensor.Create<T>(x.Lengths); 6900nint[] newLengths = Tensor.GetSmallestBroadcastableLengths(left.Lengths, right.Lengths); 6936if (input.Lengths.Length > TensorShape.MaxInlineRank) 6938curIndexArray = ArrayPool<nint>.Shared.Rent(input.Lengths.Length); 6944curIndex = stackalloc nint[input.Lengths.Length]; 6949nint rowLength = input.Lengths[^1]; 6957TensorSpanHelpers.AdjustIndexes(input.Rank - 2, 1, curIndex, input.Lengths); 6988if (input.Lengths.Length > TensorShape.MaxInlineRank) 6990curIndexArray = ArrayPool<nint>.Shared.Rent(input.Lengths.Length); 6996curIndex = stackalloc nint[input.Lengths.Length]; 7001nint rowLength = input.Lengths[^1]; 7009TensorSpanHelpers.AdjustIndexes(input.Rank - 2, 1, curIndex, input.Lengths); 7040if (input.Lengths.Length > TensorShape.MaxInlineRank) 7042curIndexArray = ArrayPool<nint>.Shared.Rent(input.Lengths.Length); 7048curIndex = stackalloc nint[input.Lengths.Length]; 7053nint rowLength = input.Lengths[^1]; 7061TensorSpanHelpers.AdjustIndexes(input.Rank - 2, 1, curIndex, input.Lengths); 7073nint[] newSize = Tensor.GetSmallestBroadcastableLengths(left.Lengths, right.Lengths); 7129TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths); 7139ispan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedRight._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedRight.Strides, broadcastedRight.Lengths)), (int)rowLength); 7142TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths); 7152ispan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedLeft._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedLeft.Strides, broadcastedLeft.Lengths)), (int)rowLength); 7155TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths); 7165ispan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedLeft._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedLeft.Strides, broadcastedLeft.Lengths)), (int)rowLength); 7166rspan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedRight._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedRight.Strides, broadcastedRight.Lengths)), (int)rowLength); 7169TensorSpanHelpers.AdjustIndexes(broadcastedLeft.Rank - 2, 1, curIndex, broadcastedLeft.Lengths);
System\Numerics\Tensors\netcore\TensorHelpers.cs (4)
96=> tensor1.Lengths.SequenceEqual(tensor2.Lengths); 110if (tensor._shape.Strides[i] != TensorPrimitives.Product(tensor.Lengths.Slice(i + 1, tensor.Lengths.Length - i - 1)))
System\Numerics\Tensors\netcore\TensorSpan.cs (4)
592nint copyLength = srcSlice.Strides[^1] == 1 && TensorHelpers.IsContiguousAndDense(srcSlice) ? srcSlice.Lengths[^1] : 1; 597TensorSpanHelpers.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); 646nint copyLength = srcSlice.Strides[^1] == 1 && TensorHelpers.IsContiguousAndDense(srcSlice) ? srcSlice.Lengths[^1] : 1; 651TensorSpanHelpers.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);