Intellisense not working on custom C++ operators

username: fsoler
cooked: <p>I am trying to follow the <a href="https://pytorch.org/tutorials/advanced/cpp_custom_ops.html" rel="noopener nofollow ugc">Custom C++ and CUDA Operators</a> tutorial on pytorch 2.4. After cloning the <a href="https://github.com/pytorch/extension-cpp" rel="noopener nofollow ugc">github repo</a> 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.</p>
<p>Im working on a virtualenv on python 3.11.7 and torch 2.4.0+cu121. I have been able to succesfully include <em>torch/extension.h</em> without any intellisense errors by adding the next paths to the includePath on the c_cpp_properties.json:</p>
<ul>
<li>/home/fsoler/.local/pythoninstalls/python3.11.7/include/python3.11</li>
<li>/home/fsoler/envs/tutorial-cppoperator/lib/python3.11/site-packages/torch/include/torch/csrc/api/include/</li>
<li>/home/fsoler/envs/tutorial-cppoperator/lib/python3.11/site-packages/torch/include/</li>
</ul>
<p>Despite <em>torch/extension.h</em> being correctly included, many errors are shown by intellisense</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/a/2/a26bf7a8da846e46acddeacc9076b69ddaf0543c.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/a26bf7a8da846e46acddeacc9076b69ddaf0543c" title="errors"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/a/2/a26bf7a8da846e46acddeacc9076b69ddaf0543c_2_689x500.jpeg" alt="errors" data-base62-sha1="naQFuXmVgJI7EIvLR6unkDTW7k8" width="689" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/a/2/a26bf7a8da846e46acddeacc9076b69ddaf0543c_2_689x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/a/2/a26bf7a8da846e46acddeacc9076b69ddaf0543c_2_1033x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/a/2/a26bf7a8da846e46acddeacc9076b69ddaf0543c.jpeg 2x" data-dominant-color="262828"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">errors</span><span class="informations">1189×862 128 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>The most prolific errors are:</p>
<ul>
<li>incomplete type “at::Tensor” is not allowed</li>
<li>namespace “torch” has no member “empty”</li>
</ul>
<p>Thanks in advance!</p>

username: Konemu
cooked: <p>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.</p>

username: fsoler
cooked: <p>I could not solve the issue, sorry. I ended up programming without intellisense ;(</p>

username: Konemu
cooked: <p>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.</p>

username: Konemu
cooked: <p>To clarify: It was wrongly configured in VS Code’s intellisense settings.</p>

username: fsoler
cooked: <p>Wait, that fixes it for me too. Thank you <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>