‘tensor’ is not a class, namespace, or enumeration


I am very new to C++ and I was following this tutorial to run the first code.

When I ran cmake --build . --config Release, I got the following error:

Scanning dependencies of target dcgan
[ 50%] Building CXX object CMakeFiles/dcgan.dir/dcgan.cpp.o
/home/sarvagya/Desktop/cpp/dcgan/dcgan.cpp: In function ‘int main()’:
/home/sarvagya/Desktop/cpp/dcgan/dcgan.cpp:5:25: error: ‘tensor’ is not a class, namespace, or enumeration
    5 |  torch::Tensor tensor = tensor::eye(3);
      |                         ^~~~~~
make[2]: *** [CMakeFiles/dcgan.dir/build.make:63: CMakeFiles/dcgan.dir/dcgan.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/dcgan.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

What am I doing wrong?

The example is defined as

int main() {
  torch::Tensor tensor = torch::eye(3);
  std::cout << tensor << std::endl;

so it seems you’ve changed the torch::eye call to tensor::eye.
Could you revert this change and retry the build?

No. This was so clumsy of me. I am sorry I created this topic. Should I delete it? It’s not going to help anyone.