Skip to content

Commit aac080e

Browse files
committed
type stability chenanigans
1 parent 6310553 commit aac080e

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

ext/MPSKitAdaptExt.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ function Adapt.adapt_structure(to, mps::InfiniteMPS)
2626
AR = map(ad, mps.AR)
2727
C = map(ad, mps.C)
2828
AC = map(ad, mps.AC)
29-
3029
return InfiniteMPS{eltype(AL), eltype(C)}(AL, AR, C, AC)
3130
end
3231

33-
Adapt.adapt_structure(to, mpo::MPO) = MPO(map(adapt(to), mpo.O))
34-
35-
Adapt.adapt_structure(to, W::MPSKit.JordanMPOTensor) =
32+
# inline to improve type stability with closures
33+
@inline Adapt.adapt_structure(to, mpo::MPO) = MPO(map(adapt(to), mpo.O))
34+
@inline Adapt.adapt_structure(to, W::MPSKit.JordanMPOTensor) =
3635
MPSKit.JordanMPOTensor(space(W), adapt(to, W.A), adapt(to, W.B), adapt(to, W.C), adapt(to, W.D))
37-
38-
Adapt.adapt_structure(to, mpo::MPOHamiltonian) = MPOHamiltonian(map(adapt(to), mpo.W))
36+
@inline Adapt.adapt_structure(to, mpo::MPOHamiltonian) =
37+
MPOHamiltonian(map(adapt(to), mpo.W))
3938

4039
end

0 commit comments

Comments
 (0)