Unknown builtin op: aten::bool

username: dalalaa
cooked: <p>Which function can be used to replace <code>tensor.bool()</code>?</p>
<pre><code class="lang-auto">Traceback (most recent call last):
  File "/home/dai/scripts/mobileocr/detector/mobilenet_east_deploy_v2.py", line 311, in &lt;module&gt;
    script_module = torch.jit.script(net)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/__init__.py", line 1203, in script
    return torch.jit.torch.jit._recursive.recursive_script(obj)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/_recursive.py", line 173, in recursive_script
    return copy_to_script_module(mod, overload_stubs + stubs)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/_recursive.py", line 95, in copy_to_script_module
    torch.jit._create_methods_from_stubs(script_module, stubs)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/__init__.py", line 1423, in _create_methods_from_stubs
    self._c._create_methods(self, defs, rcbs, defaults)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/_recursive.py", line 222, in try_compile_fn
    return torch.jit.script(fn, _rcb=rcb)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/__init__.py", line 1226, in script
    fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj))
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/_recursive.py", line 222, in try_compile_fn
    return torch.jit.script(fn, _rcb=rcb)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/__init__.py", line 1226, in script
    fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj))
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/_recursive.py", line 222, in try_compile_fn
    return torch.jit.script(fn, _rcb=rcb)
  File "/home/dai/py36env/lib/python3.6/site-packages/torch/jit/__init__.py", line 1226, in script
    fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj))
RuntimeError: 
Unknown builtin op: aten::bool.
Here are some suggestions: 
	aten::Bool
	aten::roll

The original call is:
at /home/dai/scripts/mobileocr/detector/mobilenet_east_deploy_v2.py:291:88
def is_valid_poly_torch(res,score_shape,scale:int):
    # cnt = 0
    # for i in range(res.shape[1]):
    #     if res[0,i] &lt; 0 or res[0,i] &gt;= score_shape[1] * 4 or \
    #         res[1,i] &lt; 0 or res[1,i] &gt;= score_shape[0] * 4:
    #         cnt += 1
    # return True if cnt &lt;= 1 else False
    print("res shape",res.shape)
    cnt = torch.sum(
        (res[:,0,:] &lt; 0) + (res[:,0,:] &gt;= score_shape[1] * scale) + (res[:,1,:] &lt; 0) + (res[:,1,:] &gt;= score_shape[0] * scale).bool(),
                                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ &lt;--- HERE
        dim = 1
    )
    print("cnt shape",cnt.shape)
    return cnt &lt;= 1
</code></pre>

username: driazati
cooked: <p>This is likely a bug, can you <a href="https://github.com/pytorch/pytorch/issues/new?template=bug-report.md" rel="nofollow noopener">open an issue on GitHub</a>? Thanks!</p>

username: dalalaa
cooked: <p>Thank you for your replay, I opened an issue on Github:</p>
<aside class="onebox githubissue">
  <header class="source">
      <a href="https://github.com/pytorch/pytorch/issues/30638" target="_blank" rel="nofollow noopener">github.com/pytorch/pytorch</a>
  </header>
  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Issue">
	  <svg width="60" height="60" class="github-icon" viewbox="0 0 14 16" aria-hidden="true"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/pytorch/pytorch/issues/30638" target="_blank" rel="nofollow noopener">Unknown builtin op: aten::bool</a>
    </h4>

    <div class="github-info">
      <div class="date">
        opened <span class="discourse-local-date" data-format="ll" data-date="2019-12-03" data-time="00:55:24" data-timezone="UTC">12:55AM - 03 Dec 19 UTC</span>
      </div>


      <div class="user">
        <a href="https://github.com/Arctanxy" target="_blank" rel="nofollow noopener">
          <img alt="Arctanxy" src="https://avatars3.githubusercontent.com/u/19771342?v=4" class="onebox-avatar-inline" width="20" height="20">
          Arctanxy
        </a>
      </div>
    </div>
  </div>
</div>

<div class="github-row">
  <p class="github-content">🐛 Bug
tensor.bool() doesn't work in torch.jit.script：
Code sample to reproduce this error:
class net(torch.nn.Module):
 def __init__(self):
 super(net,self).__init__()
 def forward(self,x):
 return x.bool()
model = net()
ts...</p>
</div>

<div class="labels">
</div>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>