<p dir="auto">Hi, I ran into this non-intuitive behavior:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test = torch.Tensor([1, 2, 3, 4, 5])
test[1:] -= test[:-1]"><pre class="notranslate"><code class="notranslate">test = torch.Tensor([1, 2, 3, 4, 5])
test[1:] -= test[:-1]
</code></pre></div>
<p dir="auto">results in <code class="notranslate">test = [1, 1, 1, 1, 4]</code> for me, while the non in-place version <code class="notranslate">test[1:] = test[1:] - test[:-1]</code> returns the correct result <code class="notranslate">[1, 1, 1, 1, 1]</code>. If I put the tensor to cuda() first the output seems correct...<br>
(pytorch compiled from master '0.1.9+aaf41c6')</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="t = torch.range(1,10)
t[1:] = t[:-1] # wrong result
print(t)
t = torch.range(1,10)
t[1:] = t[:-1].clone() # right result
print(t)
t = torch.range(1, 10).numpy()
t[1:] = t[:-1] # right result
print(t)"><pre class="notranslate"><code class="notranslate">t = torch.range(1,10)
t[1:] = t[:-1] # wrong result
print(t)
t = torch.range(1,10)
t[1:] = t[:-1].clone() # right result
print(t)
t = torch.range(1, 10).numpy()
t[1:] = t[:-1] # right result
print(t)
</code></pre></div>
<p dir="auto">Note that the same (wrong?) behaviour is present in lua torch.</p>