Maybe creating the extension using scipy directly will crack the case for you. And maybe is the best thing to do in your context.
However, if you want to explore how to implement a PyTorch extension, I suggest you to take a look at the first commit of this repo 15. It’s a simple extension I implemented last year. Things changed quite a lot on the backend since then, but the idea on how it works is pretty much the same.
I guess, once you get it working really nice on an extension, you can try to submit a PR with your implementation. There are a lot of subtleties when it comes to implement your well working extension natively on PyTorch, so I guess is better to just know how to make a standalone extension work first.