Which function can be used to replace tensor.bool()
?
Traceback (most recent call last):
File "/home/dai/scripts/mobileocr/detector/mobilenet_east_deploy_v2.py", line 311, in <module>
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] < 0 or res[0,i] >= score_shape[1] * 4 or \
# res[1,i] < 0 or res[1,i] >= score_shape[0] * 4:
# cnt += 1
# return True if cnt <= 1 else False
print("res shape",res.shape)
cnt = torch.sum(
(res[:,0,:] < 0) + (res[:,0,:] >= score_shape[1] * scale) + (res[:,1,:] < 0) + (res[:,1,:] >= score_shape[0] * scale).bool(),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
dim = 1
)
print("cnt shape",cnt.shape)
return cnt <= 1