Skip to content

[JIT][script] Support method-style casts in script #10631

@jamesr66a

Description

@jamesr66a

Method-style casts such as .int() and .long() currently don't work. Example:

import torch

@torch.jit.script
def cast_to_int(x):
    return x.int()
Traceback (most recent call last):
  File "method_casts.py", line 3, in <module>
    @torch.jit.script
  File "/Users/jamesreed/onnx-fairseq/pytorch/torch/jit/__init__.py", line 351, in script
    graph = _jit_script_compile(ast, rcb)
RuntimeError: 
unknown builtin op:
@torch.jit.script
def cast_to_int(x):
    return x.int()
           ~~~~~ <--- HERE


Metadata

Metadata

Assignees

Labels

oncall: jitAdd this issue/PR to JIT oncall triage queue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions