Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown builtin op: aten::bool #30638

Arctanxy opened this issue Dec 3, 2019 · 2 comments

Unknown builtin op: aten::bool #30638

Arctanxy opened this issue Dec 3, 2019 · 2 comments


Copy link

@Arctanxy Arctanxy commented Dec 3, 2019

🐛 Bug

tensor.bool() doesn't work in torch.jit.script:

Code sample to reproduce this error:

class net(torch.nn.Module):
    def __init__(self):
    def forward(self,x):
        return x.bool()
model = net()
ts = torch.jit.script(model)

Error information:

RuntimeError                              Traceback (most recent call last)
<ipython-input-46-a62f4e0965b1> in <module>()
      5         return x.bool()
      6 model = net()
----> 7 ts = torch.jit.script(model)

E:\Program Files\Anaconda3\envs\torch\lib\site-packages\torch\jit\ in script(obj, optimize, _frames_up, _rcb)
   1202     if isinstance(obj, torch.nn.Module):
-> 1203         return torch.jit.torch.jit._recursive.recursive_script(obj)
   1205     qualified_name = _qualified_name(obj)

E:\Program Files\Anaconda3\envs\torch\lib\site-packages\torch\jit\ in recursive_script(mod, exclude_methods)
    171     filtered_methods = filter(ignore_overloaded, methods)
    172     stubs = list(map(make_stub, filtered_methods))
--> 173     return copy_to_script_module(mod, overload_stubs + stubs)

E:\Program Files\Anaconda3\envs\torch\lib\site-packages\torch\jit\ in copy_to_script_module(original, stubs)
     93             setattr(script_module, name, item)
---> 95     torch.jit._create_methods_from_stubs(script_module, stubs)
     97     # Now that methods have been compiled, take methods that have been compiled

E:\Program Files\Anaconda3\envs\torch\lib\site-packages\torch\jit\ in _create_methods_from_stubs(self, stubs)
   1421     rcbs = [m.resolution_callback for m in stubs]
   1422     defaults = [get_default_args(m.original_method) for m in stubs]
-> 1423     self._c._create_methods(self, defs, rcbs, defaults)
   1425 # For each user-defined class that subclasses ScriptModule this meta-class,

Unknown builtin op: aten::bool.
Here are some suggestions: 

The original call is:
at <ipython-input-46-a62f4e0965b1>:5:15
    def forward(self,x):
        return x.bool()
               ~~~~~~ <--- HERE

The suggestions ops can't work either.


Collecting environment information...
PyTorch version: 1.3.0+cpu
Is debug build: No
CUDA used to build PyTorch: None

OS: Microsoft Windows 7 Ultimate
GCC version: Could not collect
CMake version: version 3.12.2

Python version: 3.6
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip3] msgpack-numpy==
[pip3] numpy==1.17.0
[pip3] torch==1.3.0+cpu
[pip3] torchsummary==1.5.1
[pip3] torchvision==0.4.0+cpu
[conda] Could not extract name and version from: 'torch                             1.3.0+cpu'
[conda] Could not extract name and version from: 'torchsummary                      1.5.1'
[conda] Could not extract name and version from: 'torchvision                       0.4.0+cpu'
[conda] mkl                       2017.0.3                      0

cc @suo


This comment has been minimized.

Copy link

@peterjc123 peterjc123 commented Dec 3, 2019

I can reproduce this in 1.3.1 Windows binaries.


This comment has been minimized.

Copy link

@suo suo commented Dec 10, 2019

Unfortunately, conversion ops like tensor.bool()are bound through a legacy method and aren't automatically bound into the JIT. We know this is pretty annoying so we're trying to kill the legacy bindings, but it's a work in progress.

In the meantime, a good workaround is to do instead.

I'm going to close this because there's an existing task (#30780) that covers this particular issue, but feel free to continue to comment with any questions.

@suo suo closed this Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.