<p dir="auto">a = torch.tensor(1)<br>
b = torch.tensor(0)<br>
c = a/b (output 'Floating point exception' then crash)</p>
<p dir="auto">This seems to be an issue with TH and not pytorch, the same thing happens in lua torch.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import torch
a = torch.IntTensor([0,1])
b = torch.IntTensor([0,1])
print(a.div(b)) # Floating point exception (core dumped)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">torch</span>
<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-v">IntTensor</span>([<span class="pl-c1">0</span>,<span class="pl-c1">1</span>])
<span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-v">IntTensor</span>([<span class="pl-c1">0</span>,<span class="pl-c1">1</span>])
<span class="pl-en">print</span>(<span class="pl-s1">a</span>.<span class="pl-en">div</span>(<span class="pl-s1">b</span>)) <span class="pl-c"># Floating point exception (core dumped)</span></pre></div>
<p dir="auto">Another unrelated weirdness happens with float tensors when the answer is <code class="notranslate">inf</code></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import torch
a = torch.FloatTensor([1,1])
b = torch.FloatTensor([0,0])
a.div(b)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">torch</span>
<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-v">FloatTensor</span>([<span class="pl-c1">1</span>,<span class="pl-c1">1</span>])
<span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-v">FloatTensor</span>([<span class="pl-c1">0</span>,<span class="pl-c1">0</span>])
<span class="pl-s1">a</span>.<span class="pl-en">div</span>(<span class="pl-s1">b</span>)</pre></div>
<p dir="auto">which works on lua torch, but gives</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;repr(&lt;torch.FloatTensor at 0x7f8a012eee18&gt;) failed: RuntimeError: inconsistent tensor size at /tmp/pip-zh0a53-build/torch/lib/TH/generic/THTensorMath.c:90&gt;"><pre class="notranslate"><code class="notranslate">&lt;repr(&lt;torch.FloatTensor at 0x7f8a012eee18&gt;) failed: RuntimeError: inconsistent tensor size at /tmp/pip-zh0a53-build/torch/lib/TH/generic/THTensorMath.c:90&gt;
</code></pre></div>
<p dir="auto">in pytorch.</p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ezyang/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ezyang">@ezyang</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/gchanan/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/gchanan">@gchanan</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/zou3519/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/zou3519">@zou3519</a></p>