Torch.jit.script is failing due to unfold?

qwe123: <p>We use libtorch to deploy, using the following program:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/e/3ec787870bec8f49cdab3d60d7c799c8f44c23c9.png" data-download-href="https://discuss.pytorch.org/uploads/default/3ec787870bec8f49cdab3d60d7c799c8f44c23c9" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/3/e/3ec787870bec8f49cdab3d60d7c799c8f44c23c9_2_690x170.png" alt="image" data-base62-sha1="8Xn5LhrvVYMhUKCoiGIVJesqx1n" width="690" height="170" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/3/e/3ec787870bec8f49cdab3d60d7c799c8f44c23c9_2_690x170.png, https://discuss.pytorch.org/uploads/default/optimized/3X/3/e/3ec787870bec8f49cdab3d60d7c799c8f44c23c9_2_1035x255.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/3/e/3ec787870bec8f49cdab3d60d7c799c8f44c23c9_2_1380x340.png 2x" data-dominant-color="323030"><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">image</span><span class="informations">1392×343 33.2 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><br>
But when it comes to the following        unfold ：<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/7/77c3a4082301c8ab8130932498818869b34e4d50.png" data-download-href="https://discuss.pytorch.org/uploads/default/77c3a4082301c8ab8130932498818869b34e4d50" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/7/77c3a4082301c8ab8130932498818869b34e4d50_2_690x24.png" alt="image" data-base62-sha1="h5tYAX9joBHURwbwoOKorrH4Gbe" width="690" height="24" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/7/77c3a4082301c8ab8130932498818869b34e4d50_2_690x24.png, https://discuss.pytorch.org/uploads/default/optimized/3X/7/7/77c3a4082301c8ab8130932498818869b34e4d50_2_1035x36.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/7/7/77c3a4082301c8ab8130932498818869b34e4d50_2_1380x48.png 2x" data-dominant-color="3F3431"><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">image</span><span class="informations">1739×63 11.7 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><br>
happen<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/f/6/f6cdae7fa55aa11f655d06f72a346525ba6d7b50.png" data-download-href="https://discuss.pytorch.org/uploads/default/f6cdae7fa55aa11f655d06f72a346525ba6d7b50" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/f/6/f6cdae7fa55aa11f655d06f72a346525ba6d7b50_2_690x65.png" alt="image" data-base62-sha1="zdk7Ylm7UieGS1OmNFjKVdHieGI" width="690" height="65" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/f/6/f6cdae7fa55aa11f655d06f72a346525ba6d7b50_2_690x65.png, https://discuss.pytorch.org/uploads/default/optimized/3X/f/6/f6cdae7fa55aa11f655d06f72a346525ba6d7b50_2_1035x97.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/f/6/f6cdae7fa55aa11f655d06f72a346525ba6d7b50_2_1380x130.png 2x" data-dominant-color="302F31"><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">image</span><span class="informations">1677×158 18.8 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>

ptrblck: <p><code>F.unfold</code> works for me in TorchScript:</p>
<pre><code class="lang-python">def fun(x):
    out = F.unfold(x, kernel_size=2, stride=2, padding=0)
    return out

x = torch.randn(10, 10, 10, 10)
out = fun(x)

fun_scripted = torch.jit.script(fun)
out_scripted = fun_scripted(x)

print((out - out_scripted).abs().max())
# tensor(0.)
</code></pre>