From b545380edff690490b2d8b84d450bf7a2b24a2a7 Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Thu, 9 Jan 2025 19:27:50 -0800 Subject: [PATCH 1/4] Call `Tensor::alias()` when concatenating a list of count 1 --- .../Tensor/torch.IndexingSlicingJoiningMutatingOps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From ff738129e1d8d65d89e8c72b0c592f369730b0ab Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:20:35 -0800 Subject: [PATCH 2/4] multi_dot also --- src/TorchSharp/LinearAlgebra.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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()) { From cd565a252b7fd69cae62bb48e5f2eb742eec2adb Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:26:18 -0800 Subject: [PATCH 3/4] broadcast_tensors --- src/TorchSharp/Tensor/torch.OtherOperations.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From c77f71ca70b9aad9b1023c11072aa744cffc7e9a Mon Sep 17 00:00:00 2001 From: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> Date: Tue, 25 Mar 2025 10:42:54 -0400 Subject: [PATCH 4/4] Add release notes --- RELEASENOTES.md | 1 + 1 file changed, 1 insertion(+) 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