Skip to content

Cannot trace ~ correctly #20923

@zdevito

Description

@zdevito

🐛 Bug

Tracing ~ hard codes size.

import torch

def foo(x):
    return ~x

y = torch.jit.trace(foo, torch.zeros(3,4, dtype=torch.uint8))
print(y.code)

Output:

def foo(x: Tensor) -> Tensor:
  _0 = torch.empty([3, 4], dtype=0, layout=0, device=torch.device("cpu"), pin_memory=False)
  _1 = torch.sub_(torch.fill_(_0, 1), x, alpha=1)
  return _1

cc @suo

Metadata

Metadata

Assignees

Labels

jit-backlogoncall: jitAdd this issue/PR to JIT oncall triage queuetriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions