Skip to content

Commit

Permalink
Synchronize the collection of symbolic torch ops
Browse files Browse the repository at this point in the history
  • Loading branch information
penguin-wwy committed Apr 26, 2024
1 parent 634a796 commit dfd311c
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions python/torch_mlir/extras/fx_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,26 +236,18 @@
# set and just check key existence in SYMBOLIC_OP_TO_TORCH_OP

if _IS_TORCH_2_1_OR_EARLIER:
SYMBOLIC_TORCH_OPS = {
torch.ops.aten.sym_size,
torch.ops.aten.sym_stride,
torch.ops.aten.sym_numel,
}

SYMBOLIC_OP_TO_TORCH_OP = {
(torch.ops.aten.sym_size, 1): torch.ops.aten.size.default,
(torch.ops.aten.sym_size, 2): torch.ops.aten.size.int,
(torch.ops.aten.sym_stride, 1): torch.ops.aten.stride.default,
(torch.ops.aten.sym_stride, 2): torch.ops.aten.stride.int,
(torch.ops.aten.sym_numel, 1): torch.ops.aten.numel.default,
}
else:

SYMBOLIC_TORCH_OPS = {
torch.ops.aten.sym_size.int,
torch.ops.aten.sym_stride.int,
torch.ops.aten.sym_numel.default,
x[0] for x in SYMBOLIC_OP_TO_TORCH_OP
}

else:
SYMBOLIC_OP_TO_TORCH_OP = {
torch.ops.aten.sym_size.default: torch.ops.aten.size.default,
torch.ops.aten.sym_size.int: torch.ops.aten.size.int,
Expand All @@ -264,6 +256,10 @@
torch.ops.aten.sym_numel.default: torch.ops.aten.numel.default,
}

SYMBOLIC_TORCH_OPS = {
x for x in SYMBOLIC_OP_TO_TORCH_OP
}


@dataclass(frozen=True)
class SparsityMeta:
Expand Down

0 comments on commit dfd311c

Please sign in to comment.