<p dir="auto">All flavours of ReflectionPad should accept 0-dim batch size.</p>
<p dir="auto">Tests:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="def test_ReflectionPad1d_Forward():
    z = torch.ones(0,3,10)
    m = torch.nn.ReflectionPad1d(2)
    m(z)

def test_ReflectionPad1d_Backward():
    z = torch.ones(0,3,10)
    m = torch.nn.ReflectionPad1d(2)
    m(z).sum().backward()

def test_ReflectionPad2d_Forward():
    z = torch.ones(0,3,10,10)
    m = torch.nn.ReflectionPad2d(2)
    m(z)

def test_ReflectionPad2d_Backward():
    z = torch.ones(0,3,10,10)
    m = torch.nn.ReflectionPad2d(2)
    m(z).sum().backward()"><pre class="notranslate"><span class="pl-k">def</span> <span class="pl-en">test_ReflectionPad1d_Forward</span>():
    <span class="pl-s1">z</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-en">ones</span>(<span class="pl-c1">0</span>,<span class="pl-c1">3</span>,<span class="pl-c1">10</span>)
    <span class="pl-s1">m</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-s1">nn</span>.<span class="pl-v">ReflectionPad1d</span>(<span class="pl-c1">2</span>)
    <span class="pl-en">m</span>(<span class="pl-s1">z</span>)

<span class="pl-k">def</span> <span class="pl-en">test_ReflectionPad1d_Backward</span>():
    <span class="pl-s1">z</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-en">ones</span>(<span class="pl-c1">0</span>,<span class="pl-c1">3</span>,<span class="pl-c1">10</span>)
    <span class="pl-s1">m</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-s1">nn</span>.<span class="pl-v">ReflectionPad1d</span>(<span class="pl-c1">2</span>)
    <span class="pl-en">m</span>(<span class="pl-s1">z</span>).<span class="pl-en">sum</span>().<span class="pl-en">backward</span>()

<span class="pl-k">def</span> <span class="pl-en">test_ReflectionPad2d_Forward</span>():
    <span class="pl-s1">z</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-en">ones</span>(<span class="pl-c1">0</span>,<span class="pl-c1">3</span>,<span class="pl-c1">10</span>,<span class="pl-c1">10</span>)
    <span class="pl-s1">m</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-s1">nn</span>.<span class="pl-v">ReflectionPad2d</span>(<span class="pl-c1">2</span>)
    <span class="pl-en">m</span>(<span class="pl-s1">z</span>)

<span class="pl-k">def</span> <span class="pl-en">test_ReflectionPad2d_Backward</span>():
    <span class="pl-s1">z</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-en">ones</span>(<span class="pl-c1">0</span>,<span class="pl-c1">3</span>,<span class="pl-c1">10</span>,<span class="pl-c1">10</span>)
    <span class="pl-s1">m</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-s1">nn</span>.<span class="pl-v">ReflectionPad2d</span>(<span class="pl-c1">2</span>)
    <span class="pl-en">m</span>(<span class="pl-s1">z</span>).<span class="pl-en">sum</span>().<span class="pl-en">backward</span>()</pre></div>
<h2 dir="auto"><g-emoji class="g-emoji" alias="rocket" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f680.png">🚀</g-emoji> Feature</h2>
<p dir="auto">Add support for NHWC images for upsampling nearest in CUDA.</p>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="474078293" data-permission-text="Title is private" data-url="https://github.com/pytorch/vision/issues/1179" data-hovercard-type="issue" data-hovercard-url="/pytorch/vision/issues/1179/hovercard?comment_id=558197607&amp;comment_type=issue_comment" href="https://github.com/pytorch/vision/issues/1179#issuecomment-558197607">pytorch/vision#1179 (comment)</a></p>
<h2 dir="auto">Motivation</h2>
<p dir="auto">We need this work in order to match the work from <a href="https://github.com/pytorch/pytorch/pull/34597" data-hovercard-type="pull_request" data-hovercard-url="/pytorch/pytorch/pull/34597/hovercard">This PR</a> and have feature parity with CPU.</p>
<p dir="auto">In addition, this would help us further support an ongoing work done with <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/fmassa/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/fmassa">@fmassa</a>  to have efficient <a href="https://github.com/pytorch/pytorch/pull/34597" data-hovercard-type="pull_request" data-hovercard-url="/pytorch/pytorch/pull/34597/hovercard">native image reading ops </a> in <code class="notranslate">torchvision</code>.</p>
<h2 dir="auto">Pitch</h2>
<p dir="auto">I propose the replicate work done in This PR](<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="579440339" data-permission-text="Title is private" data-url="https://github.com/pytorch/pytorch/issues/34597" data-hovercard-type="pull_request" data-hovercard-url="/pytorch/pytorch/pull/34597/hovercard" href="https://github.com/pytorch/pytorch/pull/34597">#34597</a>)  and add a new code path as it was done here:</p>
<p dir="auto"><a href="https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/cpu/UpSampleKernel.cpp#L342-L351">https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/cpu/UpSampleKernel.cpp#L342-L351</a></p>
<p dir="auto">This approach is simple. We would also stay consistent with the approach already taken. However, it's going to be hard to avoid unnecessary code duplication. I'll do my best.</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/fmassa/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/fmassa">@fmassa</a> , <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/VitalyFedyunin/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/VitalyFedyunin">@VitalyFedyunin</a> Thoughts?</p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ngimel/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ngimel">@ngimel</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/VitalyFedyunin/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/VitalyFedyunin">@VitalyFedyunin</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/jamesr66a/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/jamesr66a">@jamesr66a</a></p>