Libtorch sequential missing an #include?

OS: Ubuntu 18.04
libtorch: 1.4

I’ve set up libtorch as described on the site and been using it for a few weeks without problems. Now trying to use Sequential and as soon as I add the following line I can’t build:

#include “torch/nn/modules/container/sequential.h”

libcpp/libtorch/include/torch/csrc/api/include/torch/nn/modules/container/sequential.h:118:49: error: ‘NamedAnyModule’ was not declared in this scope
explicit SequentialImpl(std::initializer_list named_modules) {

The error message is pretty clear and it’s obvious what to do… but I’m new to c++ and libtorch so I seriously doubts that I found a problem in libtorch itself and I keep thinking I must be doing something wrong. Yet, I haven’t run in any other problem with libtorch and if I go in sequential.h and do the following modifications then I can build:

  1. add #include “torch/nn/modules/container/named_any.h”
  2. add torch::nn:: in front of every NamedAnyModule

I looked at sequential.h in libtorch 1.5 and it looks the same.

Does anyone else have the same problem?


The safe bet for you here would be to #include "torch/torch.h" to avoid any further issue

But 1) sounds like the right fix. Can you send a PR adding this include to sequential.h?

Thanks and yes, I will send a PR.