Cpp extension error when including torch/extension.h

Hi,

I am creating a custom c++ extension but I get an error on compiling when I add #include <torch/extension.h> with the error:

pytorch/torch/include/torch/csrc/api/include/torch/ordered_dict.h:13:7: error: redefinition of 'OrderedDict'
class OrderedDict {
      ^
pytorch/torch/csrc/api/include/torch/ordered_dict.h:13:7: note: previous definition is here
class OrderedDict {

My setup.py looks like:

setup(
    name="pytorch_extension",
    version="0.1",
    description="PyTorch Extension",
    packages=find_packages(exclude=['build']),
    install_requires=[],
    ext_modules=[
        CppExtension(
            'EXTENSION_NAME',
            sources,
            include_dirs=include_dirs,
            extra_compile_args=extra_compile_args,
            library_dirs=[],
            extra_link_args=[]
        ),
    ],
    cmdclass={
        'build_ext': BuildExtension,
        'clean': Clean,
    }
)
// Fails
#include "torch/extension.h" 
// #include "torch/csrc/jit/python/pybind.h" (works)

PYBIND11_MODULE(EXTENSION_NAME, m) {
  ...   
}

Are you using the latest libtorch version or a previous one?
Were you able to reproduce this issue with the single import or would we need something else to reproduce it?

I do have the latest version of libtorch and I was seeing the problem only when I included extension.h but I noticed some extra include_dirs in my setup.py that was not needed.

Thanks

Did you solve it by removing these dirs?
I just tried to build the tutorial C++ extension and it works with fine, if I include extension.h.