From be69ae19f8a03e591ecac2ca09f135f7bb0398c4 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Mon, 22 Aug 2022 21:58:51 -0400 Subject: [PATCH] allow for setting tags in operators --- Project.toml | 2 +- src/differentiation/jaches_products.jl | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index 99b38209..95c4b3bb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SparseDiffTools" uuid = "47a9eef4-7e08-11e9-0b38-333d64bd3804" authors = ["Pankaj Mishra ", "Chris Rackauckas "] -version = "1.25.1" +version = "1.25.2" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/src/differentiation/jaches_products.jl b/src/differentiation/jaches_products.jl index 0c501fa9..d3627d82 100644 --- a/src/differentiation/jaches_products.jl +++ b/src/differentiation/jaches_products.jl @@ -195,10 +195,10 @@ struct JacVec{F,T1,T2,xType} autodiff::Bool end -function JacVec(f, x::AbstractArray; autodiff = true) +function JacVec(f, x::AbstractArray, tag = DeivVecTag(); autodiff = true) if autodiff - cache1 = Dual{typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(tuple.(x))) - cache2 = Dual{typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(tuple.(x))) + cache1 = Dual{typeof(ForwardDiff.Tag(tag,eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(tuple.(x))) + cache2 = Dual{typeof(ForwardDiff.Tag(tag,eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(tuple.(x))) else cache1 = similar(x) cache2 = similar(x) @@ -264,10 +264,10 @@ struct HesVecGrad{G,T1,T2,uType} autodiff::Bool end -function HesVecGrad(g, x::AbstractArray; autodiff = false) +function HesVecGrad(g, x::AbstractArray, tag = DeivVecTag(); autodiff = false) if autodiff - cache1 = Dual{typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(tuple.(x))) - cache2 = Dual{typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(tuple.(x))) + cache1 = Dual{typeof(ForwardDiff.Tag(tag,eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(tuple.(x))) + cache2 = Dual{typeof(ForwardDiff.Tag(tag,eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(tuple.(x))) else cache1 = similar(x) cache2 = similar(x)