How does pytorch determine which backend a function supports


I wrote a c++ function that receives a quantized tensor and outputs a fp32 tensor. everything compiled without errors and the python binding also works but when i try to use the function i get the following error:

RuntimeError: Could not run 'quantized::linear_my' with arguments from the 'QuantizedCPU' backend. 'quantized::linear_my' is only available for these backends: [].

so my question is how does pytorch determine which backends does my function support?
how can i fix this state where my function doesnt support any backend?


Are you using TorchBind rather than PyBind11?

I am not sure, I used the same method that was used in the torch library, I modified code inside the library.
I resolved the problem in the end, it was a compilation problem, cleaning the project resolved it.

you can take a look at how we implement quantized ops:
we need to declare the signature:

and then implement it:

1 Like