diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 721dd1a7f..f11f83cdc 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -12,6 +12,7 @@ __API Changes__: #1374 Add accumulate to index_put_
`torch.optim.lr_scheduler.PolynomialLR` `power` type has been corrected, is now double.
+Returning an input tensor has been corrected, is now `alias()`.
# NuGet Version 0.105.0 diff --git a/src/TorchSharp/LinearAlgebra.cs b/src/TorchSharp/LinearAlgebra.cs index 0abb63d1d..436650ac7 100644 --- a/src/TorchSharp/LinearAlgebra.cs +++ b/src/TorchSharp/LinearAlgebra.cs @@ -440,7 +440,7 @@ public static Tensor multi_dot(IList tensors) throw new ArgumentException(nameof(tensors)); } if (tensors.Count == 1) { - return tensors[0]; + return tensors[0].alias(); } using (var parray = new PinnedArray()) { diff --git a/src/TorchSharp/Tensor/torch.IndexingSlicingJoiningMutatingOps.cs b/src/TorchSharp/Tensor/torch.IndexingSlicingJoiningMutatingOps.cs index 8e062c786..c55ec9f4c 100644 --- a/src/TorchSharp/Tensor/torch.IndexingSlicingJoiningMutatingOps.cs +++ b/src/TorchSharp/Tensor/torch.IndexingSlicingJoiningMutatingOps.cs @@ -40,7 +40,7 @@ public static Tensor cat(IList tensors, long dim = 0) switch (tensors.Count) { case <=0: throw new ArgumentException(nameof(tensors)); - case 1: return tensors[0]; + case 1: return tensors[0].alias(); } using var parray = new PinnedArray(); diff --git a/src/TorchSharp/Tensor/torch.OtherOperations.cs b/src/TorchSharp/Tensor/torch.OtherOperations.cs index dfdb4a6ff..4edfcf715 100644 --- a/src/TorchSharp/Tensor/torch.OtherOperations.cs +++ b/src/TorchSharp/Tensor/torch.OtherOperations.cs @@ -63,7 +63,7 @@ public static IList broadcast_tensors(params Tensor[] tensors) throw new ArgumentException(nameof(tensors)); } if (tensors.Length == 1) { - return tensors; + return new Tensor[] { tensors[0].alias() }; } IntPtr[] ptrArray;