To write adjoints you will need to read the manual, and probably look at some of these examples.
Zygote’s errors are usually from 10 layers underground, I don’t quite know why each of these fails.
But I have a package solution:
julia> using Tullio, ForwardDiff, Zygote
julia> fs = [sin,cos,tan];
julia> rowmap(fs, x) = @tullio y[r,c] := begin
f = getindex(fs, r)
@inbounds f(x[r,c])
end grad=Dual;
julia> gradient(x -> sum(rowmap(fs, x)), ones(3,10))[1]
3×10 Array{Float64,2}:
0.540302 0.540302 0.540302 0.540302 … 0.540302 0.540302 0.540302 0.540302
-0.841471 -0.841471 -0.841471 -0.841471 -0.841471 -0.841471 -0.841471 -0.841471
3.42552 3.42552 3.42552 3.42552 3.42552 3.42552 3.42552 3.42552
This is probably quite efficient, compared to making slices. If you check axes(fs,1)==axes(x,1) then you could use @inbounds getindex(fs, r).