coincheung:

I noticed that in pytorch1.6, users should add decorator of @custum_fwd if they want to implement their own operators that is derived from autograd.Function


Where did you saw that? There were no changes that I’m aware of to autograd.Function in 1.6.

I have no idea whether I can call my ohem_cpp module directly as in the code above without potential errors.

Yes you can. And as long as you only use differentiable ops on the c++ side you can backprop through it.
If you don’t, then you’ll need a custom Function and you can see here how to do it.