From d65df146bbe850d3b8e3a2a61a367b2388c3de42 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Tue, 14 May 2024 21:55:32 -0400 Subject: [PATCH 1/2] [NDTensors] Fix issue in `Tensor` constructor when storage involves wrapper types (#1441) --- NDTensors/src/tensor/tensor.jl | 4 ++++ NDTensors/test/test_dense.jl | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/NDTensors/src/tensor/tensor.jl b/NDTensors/src/tensor/tensor.jl index 351e86d9c6..4dfa483030 100644 --- a/NDTensors/src/tensor/tensor.jl +++ b/NDTensors/src/tensor/tensor.jl @@ -69,6 +69,10 @@ function Tensor(as::AliasStyle, storage::TensorStorage, inds::Tuple) ) end +function Tensor(as::NeverAlias, storage::TensorStorage, inds::Tuple) + return Tensor(AllowAlias(), copy(storage), inds) +end + # Automatically convert to Tuple if the indices are not a Tuple # already (like a Vector). In the future this may be lifted # to allow for very large tensor orders in which case Tuple diff --git a/NDTensors/test/test_dense.jl b/NDTensors/test/test_dense.jl index 382661c140..78368d2841 100644 --- a/NDTensors/test/test_dense.jl +++ b/NDTensors/test/test_dense.jl @@ -38,6 +38,11 @@ NDTensors.dim(i::MyInd) = i.dim Aview = A[2:3, 2:3] @test dims(Aview) == (2, 2) + ## Added for issue 1431 create a tensor from + ## a sliced view of another tensor + Acopy = Tensor(NDTensors.storage(Aview), (1, 4)) + @test NDTensors.cpu(data(Acopy)) == NDTensors.cpu(data(Aview)) + @test dims(Acopy) == (1, 4) B = dev(Tensor(elt, undef, (3, 4))) randn!(B) From ffbb1f94c8f3f74a195a4cd8ccfce0932351142f Mon Sep 17 00:00:00 2001 From: Matt Fishman Date: Tue, 14 May 2024 21:56:13 -0400 Subject: [PATCH 2/2] [NDTensors] Bump to v0.3.7 [no ci] --- NDTensors/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NDTensors/Project.toml b/NDTensors/Project.toml index d5aebfe81b..2e5232a359 100644 --- a/NDTensors/Project.toml +++ b/NDTensors/Project.toml @@ -1,7 +1,7 @@ name = "NDTensors" uuid = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" authors = ["Matthew Fishman "] -version = "0.3.6" +version = "0.3.7" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"