gradcheck is supposed to work with doubles and will fail for types of less precision.
I’m not sure how to debug your code further, as it seems the gradients are correct.
What are your doubts about your code?