I attempt to used reverse mode differentiation. A very much simplified version of the function call is
using StaticArrays
using ReverseDiff
const Po{T} = SArray{Tuple{2},T,1,2} # point in R2
function ff(x)
T = eltype(x)
y = reinterpret(Po{T}, x)
sum(sum(y))
end
x = rand(10)
ff(x)
ReverseDiff.gradient(ff,x)
I get an argumenterror due to the reinterpret
line. Is there some way to work around this? [Note that the function call may look like a superinefficient way to compute the sum of the input array; but in the actual program the reinterpret step is necessary.]
The exact error message is as follows
ERROR: ArgumentError: cannot reinterpret `ReverseDiff.TrackedReal{Float64,Float64,ReverseDiff.TrackedArray{Float64,Float64,1,Array{Float64,1},Array{Float64,1}}}` `SArray{Tuple{2},ReverseDiff.TrackedReal{Float64,Float64,ReverseDiff.TrackedArray{Float64,Float64,1,Array{Float64,1},Array{Float64,1}}},1,2}`, type `SArray{Tuple{2},ReverseDiff.TrackedReal{Float64,Float64,ReverseDiff.TrackedArray{Float64,Float64,1,Array{Float64,1},Array{Float64,1}}},1,2}` is not a bits type