Skip to content

Commit 5c5e65a

Browse files
committed
Register node visitor for _clone_dim_order
1 parent 5546360 commit 5c5e65a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright 2024-2025 Arm Limited and/or its affiliates.
2+
#
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
# pyre-unsafe
7+
from typing import Any, List
8+
9+
import torch
10+
11+
from executorch.backends.arm.operators.node_visitor import (
12+
NodeVisitor,
13+
register_node_visitor,
14+
)
15+
from executorch.backends.arm.operators.operator_validation_utils import (
16+
validate_num_inputs,
17+
)
18+
from executorch.backends.arm.tosa_mapping import TosaArg
19+
20+
21+
@register_node_visitor
22+
class CloneDimOrderVisitor(NodeVisitor):
23+
"""
24+
Implement _clone_dim_order as an identity operation.
25+
"""
26+
27+
target = "dim_order_ops._clone_dim_order.default"
28+
29+
tosa_specs = NodeVisitor.tosa_specs
30+
31+
def define_node(
32+
self,
33+
node: torch.fx.Node,
34+
tosa_graph: Any,
35+
inputs: List[TosaArg],
36+
output: TosaArg,
37+
) -> None:
38+
import serializer.tosa_serializer as ts # type: ignore
39+
40+
validate_num_inputs(self.target, inputs, 1)
41+
42+
# Since only contiguous dim order is currently supported, treat clone as an identity op.
43+
tosa_graph.addOperator(ts.TosaOp.Op().IDENTITY, [inputs[0].name], [output.name])

0 commit comments

Comments
 (0)