From 94aa51f543c70df4c410f9e4cbb7a4dea2042cb2 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Mon, 11 May 2026 09:52:47 +0200 Subject: [PATCH 1/4] fix: proper eltype in wrong-mode pushforward/pullback --- DifferentiationInterface/Project.toml | 2 +- DifferentiationInterface/src/utils/linalg.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DifferentiationInterface/Project.toml b/DifferentiationInterface/Project.toml index 2fd7884ce..a78e5c371 100644 --- a/DifferentiationInterface/Project.toml +++ b/DifferentiationInterface/Project.toml @@ -1,6 +1,6 @@ name = "DifferentiationInterface" uuid = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" -version = "0.7.17" +version = "0.7.18" authors = ["Guillaume Dalle", "Adrian Hill"] [deps] diff --git a/DifferentiationInterface/src/utils/linalg.jl b/DifferentiationInterface/src/utils/linalg.jl index e11b7e266..2cb6470c3 100644 --- a/DifferentiationInterface/src/utils/linalg.jl +++ b/DifferentiationInterface/src/utils/linalg.jl @@ -44,5 +44,5 @@ Convert an array of tuples `tx` into a tuple of arrays, while respecting the arr arroftup_to_tupofarr(tx::NTuple{B, <:Number}, x::Number) where {B} = tx function arroftup_to_tupofarr(tx::AbstractArray{<:NTuple{B, <:Number}}, x::AbstractArray{<:Number}) where {B} - return ntuple(b -> similar(x) .= getindex.(tx, b), Val(B)) + return ntuple(b -> similar(x, eltype(tx)) .= getindex.(tx, b), Val(B)) end From 323aed19da62ac760a7a54e68da86f17ab19b1af Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Mon, 11 May 2026 10:10:40 +0200 Subject: [PATCH 2/4] Fix --- DifferentiationInterface/src/utils/linalg.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DifferentiationInterface/src/utils/linalg.jl b/DifferentiationInterface/src/utils/linalg.jl index 2cb6470c3..aaa22f50f 100644 --- a/DifferentiationInterface/src/utils/linalg.jl +++ b/DifferentiationInterface/src/utils/linalg.jl @@ -43,6 +43,6 @@ Convert an array of tuples `tx` into a tuple of arrays, while respecting the arr """ arroftup_to_tupofarr(tx::NTuple{B, <:Number}, x::Number) where {B} = tx -function arroftup_to_tupofarr(tx::AbstractArray{<:NTuple{B, <:Number}}, x::AbstractArray{<:Number}) where {B} - return ntuple(b -> similar(x, eltype(tx)) .= getindex.(tx, b), Val(B)) +function arroftup_to_tupofarr(tx::AbstractArray{<:NTuple{B, TX}}, x::AbstractArray{<:Number}) where {B, TX <: Number} + return ntuple(b -> similar(x, TX) .= getindex.(tx, b), Val(B)) end From fce7cbf127833444f3fae2476c8f6974b1e58e68 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Mon, 11 May 2026 11:44:12 +0200 Subject: [PATCH 3/4] Without type parameter to avoid angering Aqua --- DifferentiationInterface/src/utils/linalg.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DifferentiationInterface/src/utils/linalg.jl b/DifferentiationInterface/src/utils/linalg.jl index aaa22f50f..b27706a5e 100644 --- a/DifferentiationInterface/src/utils/linalg.jl +++ b/DifferentiationInterface/src/utils/linalg.jl @@ -43,6 +43,6 @@ Convert an array of tuples `tx` into a tuple of arrays, while respecting the arr """ arroftup_to_tupofarr(tx::NTuple{B, <:Number}, x::Number) where {B} = tx -function arroftup_to_tupofarr(tx::AbstractArray{<:NTuple{B, TX}}, x::AbstractArray{<:Number}) where {B, TX <: Number} - return ntuple(b -> similar(x, TX) .= getindex.(tx, b), Val(B)) +function arroftup_to_tupofarr(tx::AbstractArray{<:NTuple{B, <:Number}}, x::AbstractArray{<:Number}) where {B} + return ntuple(b -> similar(x, eltype(eltype(tx))) .= getindex.(tx, b), Val(B)) end From d176bc6c32884fac278b260abac8864d6e796a0e Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Mon, 11 May 2026 13:25:52 +0200 Subject: [PATCH 4/4] Changelog --- DifferentiationInterface/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DifferentiationInterface/CHANGELOG.md b/DifferentiationInterface/CHANGELOG.md index 5decdf9dc..93173bf13 100644 --- a/DifferentiationInterface/CHANGELOG.md +++ b/DifferentiationInterface/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add support for HyperHessians backend ([#940](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/940)) +### Fixed + +- Proper eltype in wrong-mode pushforward/pullback ([#1003](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/1003)) + ## [0.7.17](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.16...DifferentiationInterface-v0.7.17) ### Fixed