Thanks, this is what I was missing and couldn’t find.
Thanks, I have the gradients defined in another C file which is why I modeled this example like that. I do wish it were easier to scaffold the FFI stuff like this.
I will try to use reverse_pass_callback for this once I’ve got the gradients from the C function, as outlined here.