Skip to content

torch.lu(A) traces but doesn't script #33381

@andrewdelong

Description

@andrewdelong

🐛 Bug

torch.lu can be traced, but script compilation raises Unknown builtin op: aten::lu error.

To Reproduce

def f(A, b):
    return torch.lu_solve(b, *torch.lu(A))

A = torch.eye(3)
b = torch.ones((3, 1))

torch.jit.trace(f, (A, b))  # <-- OK
torch.jit.script(f)         # <-- Unknown builtin op: aten::lu

Using torch.solve or torch.cholsky+torch.cholesky_solve works fine.

Workaround

Trace torch.lu and then call it from the script:

lu_trace = torch.jit.trace(torch.lu, torch.eye(2))

@torch.jit.script
def f(A, b):
    return torch.lu_solve(b, *lu_trace(A))  # <-- OK

Environment

  • PyTorch 1.4.0
  • MacOS
  • conda install
  • Python 3.7.6
  • CPU only

cc @suo

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