Skip to content

Commit

Permalink
Merge branch 'main' into kmp5/debug/issue_1430
Browse files Browse the repository at this point in the history
  • Loading branch information
kmp5VT authored May 15, 2024
2 parents ef4e5e7 + ffbb1f9 commit 5466fff
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion NDTensors/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NDTensors"
uuid = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"
authors = ["Matthew Fishman <[email protected]>"]
version = "0.3.6"
version = "0.3.7"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
4 changes: 4 additions & 0 deletions NDTensors/src/tensor/tensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions NDTensors/test/test_dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5466fff

Please sign in to comment.