"round" "_vml_cpu" not implemented for 'Char'

Sairam954: <p>I am getting this error while using round method.  I printed the tensor type to check, and it prints int8 as it should be. However, error says tensor of type Char.</p>
<p>The Code throwing the exception</p>
<pre><code class="lang-auto"> print(self.prob.mul(self.len).dtype)
 self.binary.data = self.prob.mul(self.len).round()
</code></pre>
<p>The Expection</p>
<pre><code class="lang-auto">torch.int8
Traceback (most recent call last):
  File "SCONNA.py", line 59, in &lt;module&gt;
    uconv2d = FSUConv2duGEMM(
  File "/home/sv/Desktop/Stochastic_Acc_Sim/utils/UnarySimLayers.py", line 552, in __init__
    self.weight.data = SourceGen(
  File "/home/sv/Desktop/Stochastic_Acc_Sim/utils/UnarySimUtils.py", line 504, in __init__
    self.binary.data = self.prob.mul(self.len).round()
RuntimeError: "round" "_vml_cpu" not implemented for 'Char'
</code></pre>

KFrank: <p>Hi Sairam!</p>
<aside class="quote no-group" data-username="Sairam954" data-post="1" data-topic="150488" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/sairam954/48/48574_2.png" class="avatar"> Sairam954:</div>
<blockquote>
<p>I printed the tensor type to check, and it prints int8 as it should be. However, error says tensor of type Char.</p>
</blockquote>
</aside>
<p>First, it doesn’t really make sense to “round” an integral type (as rounding<br>
an integer by definition doesn’t change its value).  So pytorch doesn’t<br>
implement <code>.round()</code> for integers.</p>
<p>Second, somewhere under the hood, pytorch uses “Char” as a synonym<br>
for <code>int8</code> – perhaps a bit confusing, but they mean the same thing.</p>
<p>(If you do the same experiment with <code>dtype</code>s <code>int16</code>, <code>int32</code>, and <code>int64</code>,<br>
you will get analogous error messages naming types “Short,”, “Int,” and<br>
“Long,” respectively.)</p>
<p>Best.</p>
<p>K. Frank</p>

Sairam954: <p>Thanks <a class="mention" href="/u/kfrank">@KFrank</a>, it makes sense. However, even for float16 it gives the similar error.</p>
<pre><code class="lang-auto">RuntimeError: "round" "_vml_cpu" not implemented for 'Half'
</code></pre>
<p>Is there a place where the supported dtypes for round method are listed?</p>

KFrank: <p>Hi Sairam!</p>
<aside class="quote no-group" data-username="Sairam954" data-post="3" data-topic="150488" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/sairam954/48/48574_2.png" class="avatar"> Sairam954:</div>
<blockquote>
<pre><code class="lang-auto">RuntimeError: "round" "_vml_cpu" not implemented for 'Half'
</code></pre>
</blockquote>
</aside>
<p>Well, that’s unexpected and somewhat annoying.  I assume that it’s<br>
just an oversight.  (I can reproduce this on versions 1.10 and 1.11.)</p>
<p>Interestingly, it does work on the gpu:</p>
<pre><code class="lang-plaintext">&gt;&gt;&gt; import torch
&gt;&gt;&gt; torch.__version__
'1.10.0'
&gt;&gt;&gt; t = torch.ones (5, dtype = torch.float16)
&gt;&gt;&gt; t
tensor([1., 1., 1., 1., 1.], dtype=torch.float16)
&gt;&gt;&gt; t.round()
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
RuntimeError: "round" "_vml_cpu" not implemented for 'Half'
&gt;&gt;&gt; t.cuda().round()
tensor([1., 1., 1., 1., 1.], device='cuda:0', dtype=torch.float16)
</code></pre>
<aside class="quote no-group">
<blockquote>
<p>Is there a place where the supported dtypes for round method are listed?</p>
</blockquote>
</aside>
<p>I’m not aware of any explicit list.  (I would have expected <code>round()</code> to work<br>
for any floating-point type, but, as you have shown, it doesn’t.)</p>
<p>Best.</p>
<p>K. Frank</p>

eqy: <p>Related upstream issue: <a href="https://github.com/pytorch/pytorch/issues/54774" rel="noopener nofollow ugc">RuntimeError: “log2” “_vml_cpu” not implemented for ‘Half’ · Issue #54774 · pytorch/pytorch (github.com)</a></p>