Skip to content

Commit 4a47817

Browse files
committed
Merge remote-tracking branch 'origin/kmp5/debug/issue_1438' into kmp5/debug/1438
2 parents e02b8b3 + 129ab75 commit 4a47817

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

NDTensors/src/tensor/tensor.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ function Tensor(as::AliasStyle, storage::TensorStorage, inds::Tuple)
6969
)
7070
end
7171

72+
function Tensor(as::NeverAlias, storage::TensorStorage, inds::Tuple)
73+
return Tensor(AllowAlias(), copy(storage), inds)
74+
end
75+
7276
# Automatically convert to Tuple if the indices are not a Tuple
7377
# already (like a Vector). In the future this may be lifted
7478
# to allow for very large tensor orders in which case Tuple

NDTensors/test/test_dense.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ NDTensors.dim(i::MyInd) = i.dim
3838

3939
Aview = A[2:3, 2:3]
4040
@test dims(Aview) == (2, 2)
41+
## Added for issue 1431 create a tensor from
42+
## a sliced view of another tensor
43+
Acopy = Tensor(NDTensors.storage(Aview), (1,4))
44+
@test @allowscalar data(Acopy) == data(Aview)
45+
@test dims(Acopy) == (1,4)
4146

4247
B = dev(Tensor(elt, undef, (3, 4)))
4348
randn!(B)

0 commit comments

Comments
 (0)