Hi,
I am using chainrulecore for gradient calculation and rrule. I am trying to follow tutorial 18 of gridap. I cant understand the ZeroTangent in the code why we are using that and what it is suppose to do. I’ve read some thing on documentations but it is not clear to me.
thank you
using ChainRulesCore, Zygote
import ChainRulesCore: rrule
NO_FIELDS = ZeroTangent()
function gf_pf(pf_vec; β, η, phys_params, fem_params)
pfh = FEFunction(fem_params.Pf, pf_vec)
pth = (pf -> Threshold(pf; β, η)) ∘ pfh
A_mat = MatrixA(pth; phys_params, fem_params)
b_vec = assemble_vector(v->(∫(v)fem_params.dΓ_s), fem_params.V)
u_vec = A_mat \ b_vec
O_mat = MatrixOf(fem_params)
real(u_vec' * O_mat * u_vec)
end
function rrule(::typeof(gf_pf), pf_vec; β, η, phys_params, fem_params)
function U_pullback(dgdg)
NO_FIELDS, dgdg * Dgfdpf(pf_vec; β, η, phys_params, fem_params)
end
gf_pf(pf_vec; β, η, phys_params, fem_params), U_pullback
end