-
Notifications
You must be signed in to change notification settings - Fork 509
/
Copy pathop_repeat.py
38 lines (30 loc) · 1.09 KB
/
op_repeat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright 2024-2025 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
# pyre-unsafe
import serializer.tosa_serializer as ts # type: ignore
import torch
from executorch.backends.arm.operators.node_visitor import (
NodeVisitor,
register_node_visitor,
)
from executorch.backends.arm.tosa_mapping import TosaArg
from executorch.backends.arm.tosa_utils import tosa_shape
from serializer.tosa_serializer import TosaOp
@register_node_visitor
class RepeatVisitor(NodeVisitor):
target = "aten.repeat.default"
def __init__(self, *args):
super().__init__(*args)
def define_node(
self,
node: torch.fx.Node,
tosa_graph: ts.TosaSerializer,
inputs: list[TosaArg],
output: TosaArg,
) -> None:
multiples = inputs[1].special
attr = ts.TosaSerializerAttribute()
attr.TileAttribute(tosa_shape(multiples, output.dim_order))
tosa_graph.addOperator(TosaOp.Op().TILE, [inputs[0].name], [output.name], attr)