Intellisense not working on custom C++ operators

I am trying to follow the Custom C++ and CUDA Operators tutorial on pytorch 2.4. After cloning the github repo and installing the extension, testing works fine. Intellisense, on the other hand shows many errors on the code which i would like to fix, since the next step is to code my own operator and intellisense comes a long way.

Im working on a virtualenv on python 3.11.7 and torch 2.4.0+cu121. I have been able to succesfully include torch/extension.h without any intellisense errors by adding the next paths to the includePath on the c_cpp_properties.json:

  • /home/fsoler/.local/pythoninstalls/python3.11.7/include/python3.11
  • /home/fsoler/envs/tutorial-cppoperator/lib/python3.11/site-packages/torch/include/torch/csrc/api/include/
  • /home/fsoler/envs/tutorial-cppoperator/lib/python3.11/site-packages/torch/include/

Despite torch/extension.h being correctly included, many errors are shown by intellisense

The most prolific errors are:

  • incomplete type “at::Tensor” is not allowed
  • namespace “torch” has no member “empty”

Thanks in advance!

1 Like

I have exactly the same problem, interestingly, and spent the better part of yesterday trying to fix it. Have you had any luck in the meantime? Any pointers would be much appreciated.

I could not solve the issue, sorry. I ended up programming without intellisense ;(

I appreciate the reply. In my case, the C++ standard had mistakenly been set to 14 instead of 17 which turned out to be the cause of the problem. Maybe this will help someone at some point.

To clarify: It was wrongly configured in VS Code’s intellisense settings.

Wait, that fixes it for me too. Thank you :slight_smile:

1 Like