Skip to content

Commit 66187bb

Browse files
authored
Small simplification of indexmanipulations (#383)
* simplify indexmanipulations * remove unnecessarily specialized code
1 parent 9422cd5 commit 66187bb

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

src/auxiliary/auxiliary.jl

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,6 @@ function _interleave(a::NTuple{N}, b::NTuple{N}) where {N}
5757
return (a[1], b[1], _interleave(tail(a), tail(b))...)
5858
end
5959

60-
# Low-overhead implementation of `copyto!` for specific case of `stride(B, 1) < stride(B, 2)`
61-
# used in indexmanipulations: avoids the overhead of Strided.jl
62-
function _copyto!(A::StridedView{<:Any, 1}, B::StridedView{<:Any, 2})
63-
length(A) == length(B) || throw(DimensionMismatch())
64-
65-
Adata = parent(A)
66-
Astr = stride(A, 1)
67-
IA = A.offset
68-
69-
Bdata = parent(B)
70-
Bstr = strides(B)
71-
72-
IB_1 = B.offset
73-
@inbounds for _ in axes(B, 2)
74-
IB = IB_1
75-
for _ in axes(B, 1)
76-
Adata[IA += Astr] = Bdata[IB += Bstr[1]]
77-
end
78-
IB_1 += Bstr[2]
79-
end
80-
81-
return A
82-
end
83-
8460
@static if VERSION < v"1.11" # TODO: remove once support for v1.10 is dropped
8561
_allequal(f, xs) = allequal(Base.Generator(f, xs))
8662
else

src/tensors/indexmanipulations.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,8 @@ function _add_transform_multi!(
701701
buffer_src = StridedView(buffer2, (blocksize, cols), (1, blocksize), 0)
702702
for (i, struct_src) in enumerate(structs_src)
703703
subblock_src = sreshape(StridedView(tsrc.data, sz_src, struct_src...), matsize)
704-
_copyto!(buffer_src[:, i], subblock_src)
704+
bufblock_src = sreshape(buffer_src[:, i], matsize)
705+
copy!(bufblock_src, subblock_src)
705706
end
706707

707708
# Resummation into a second buffer using BLAS

0 commit comments

Comments
 (0)