Taking zygote gradient on function with ! operator fails on gpu

Differentiating through boolean does really make sense as your can’t change a bool a little bit. The below works.

using Flux
masksum(x,y) = sum(1 .- x * y)

gradient(masksum, [1,0,1], .3)

gradient(masksum, [1,0,1] |> gpu, .3)
3 Likes