forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnormalize_transpose_pass.py
More file actions
24 lines (20 loc) · 881 Bytes
/
normalize_transpose_pass.py
File metadata and controls
24 lines (20 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import torch
from executorch.exir.pass_base import ExportPass
class NormalizeTransposePass(ExportPass):
"""
Even with functionalization on, we still get graph with
torch.ops.aten.t.default op. Ideally we should fix functionalization.
TODO: once we have that, we should remove this pass.
Check test_normalize_transpose_op in test_passes.py for more details
"""
def call_operator(self, op, args, kwargs, meta):
if op == torch.ops.aten.t.default:
return super().call_operator(
torch.ops.aten.t_copy.default, (args[0],), kwargs, meta
)
return super().call_operator(op, args, kwargs, meta)