Solved by ptrblck in post #2 
              
              
                You don’t need to write the C++ extensions and your current custom autograd.Function should work. 
Implementing the custom methods in C++ could yield a speedup as shown in the tutorial.