torch::nn::Sequential error with Libtorch in windows

username: maxiaoyuelun
cooked: <p>my os:<br>
windows 10<br>
libtorch 1.1<br>
visual studio 2015</p>
<p>when I code like this:<br>
<span class="hashtag">#include</span> <br>
<span class="hashtag">#include</span> “torch/script.h”<br>
<span class="hashtag">#include</span> “torch/torch.h”<br>
using namespace std;<br>
using namespace torch;<br>
int main()<br>
{<br>
nn::Sequential(nn::Conv2d(nn::Conv2dOptions(10, 256, 4)<br>
.with_bias(false)<br>
.transposed(true)));<br>
cout &lt;&lt; “Hello LibTorch” &lt;&lt; endl;<br>
return 0;<br>
}</p>
<p>I compiled and got the error:</p>
<p>D:\BUILD\libtorch_release_110\include\torch/csrc/utils/variadic.h(195): error C2059: syntax error: ‘template’<br>
D:\BUILD\libtorch_release_110\include\torch/csrc/utils/variadic.h(190): note: see reference to function template instantiation ‘ReturnType torch::unpack&lt;ReturnType,const at::Tensor&amp;,torch::nn::AnyModule::Holder&lt;torch::nn::Conv2dImpl,const at::Tensor &amp;&gt;::InvokeForward,torch::nn::AnyModule::Holder&lt;torch::nn::Conv2dImpl,const at::Tensor &amp;&gt;::CheckedGetter,0&gt;(Function,Accessor,torch::Indices&lt;0&gt;)’ being compiled<br>
with<br>
[<br>
ReturnType=torch::nn::AnyModule::Value,<br>
Function=torch::nn::AnyModule::Holder&lt;torch::nn::Conv2dImpl,const at::Tensor &amp;&gt;::InvokeForward,<br>
Accessor=torch::nn::AnyModule::Holder&lt;torch::nn::Conv2dImpl,const at::Tensor &amp;&gt;::CheckedGetter<br>
]</p>
<p>anyone can solve the problem?</p>

username: dalalaa
cooked: <p>I met the same error,did you find the solution? my os:<br>
win 7<br>
libtorch 1.0<br>
visual studio 2015</p>

username: maxiaoyuelun
cooked: <p>sorry, I have no idea about this issue. Look forward to someone official that can deal with it!<img src="https://discuss.pytorch.org/images/emoji/apple/joy.png?v=9" title=":joy:" class="emoji" alt=":joy:"></p>

username: J_S
cooked: <p>I just posted something that could be related:</p>
<aside class="quote quote-modified" data-post="1" data-topic="83266">
  <div class="title">
    <div class="quote-controls"></div>
    <img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/j/9de0a6/48.png" class="avatar">
    <a href="https://discuss.pytorch.org/t/libtorch-sequential-missing-an-include/83266">Libtorch sequential missing an #include?</a> <a class="badge-category__wrapper " href="/c/c/11"><span data-category-id="11" data-drop-close="true" class="badge-category " title="Topics related to the C++ Frontend, C++ API or C++ Extensions"><span class="badge-category__name">C++</span></span></a>
  </div>
  <blockquote>
    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” 
error: 
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…
  </blockquote>
</aside>

<p>It could be related because the first errors messages I got with Sequential were quite nebulous. I had to use SequentialImpl to get a decent error message and from there I could find a solution to my problem.</p>