Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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