Skip to content

Commit 3d2263e

Browse files
authored
Merge branch 'main' into linux_arm_build
2 parents 12fd120 + 2845fd3 commit 3d2263e

File tree

13 files changed

+205
-76
lines changed

13 files changed

+205
-76
lines changed

backends/arm/TARGETS

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Copyright 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+
16
# @noautodeps
27
load("@fbcode_macros//build_defs:python_library.bzl", "python_library")
38

@@ -12,6 +17,17 @@ python_library(
1217
":arm_partitioner",
1318
]
1419
)
20+
python_library(
21+
name = "vgf_partitioner",
22+
srcs = [
23+
"vgf/__init__.py",
24+
"vgf/backend.py",
25+
"vgf/partitioner.py"
26+
],
27+
deps = [
28+
":arm_partitioner",
29+
]
30+
)
1531
python_library(
1632
name = "constants",
1733
srcs = [
@@ -39,8 +55,6 @@ python_library(
3955
srcs = [
4056
"tosa/backend.py",
4157
"tosa/partitioner.py",
42-
"vgf_backend.py",
43-
"vgf_partitioner.py",
4458
],
4559
deps = [
4660
":arm_backend",

backends/arm/operators/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,22 @@
1515
op_avg_pool2d,
1616
op_bmm,
1717
op_cat,
18+
op_ceil,
1819
op_clamp,
1920
op_constant_pad_nd,
2021
op_conv2d,
2122
op_cos,
2223
op_eq,
2324
op_erf,
2425
op_exp,
26+
op_floor,
2527
op_ge,
2628
op_gt,
2729
op_index_select,
2830
op_index_tensor,
2931
op_le,
3032
op_log,
33+
op_logical_not,
3134
op_lt,
3235
op_max_pool2d,
3336
op_maximum,
@@ -57,5 +60,4 @@
5760
op_where,
5861
ops_binary,
5962
ops_identity,
60-
ops_unary,
6163
)

backends/arm/operators/op_ceil.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 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+
from typing import Any, List
7+
8+
import torch.fx
9+
10+
from executorch.backends.arm.operators.node_visitor import (
11+
NodeVisitor,
12+
register_node_visitor,
13+
)
14+
from executorch.backends.arm.operators.operator_validation_utils import (
15+
validate_num_inputs,
16+
validate_same_dtype,
17+
validate_valid_dtype,
18+
)
19+
from executorch.backends.arm.tosa import TosaSpecification
20+
21+
from executorch.backends.arm.tosa.mapping import TosaArg
22+
23+
24+
@register_node_visitor
25+
class CeilVisitor(NodeVisitor):
26+
target = "aten.ceil.default"
27+
28+
# INT case should be handled by op_table
29+
tosa_specs = [TosaSpecification.create_from_string("TOSA-1.0+FP")]
30+
31+
def __init__(self, *args):
32+
super().__init__(*args)
33+
34+
def define_node(
35+
self,
36+
node: torch.fx.Node,
37+
tosa_graph: Any,
38+
inputs: List[TosaArg],
39+
output: TosaArg,
40+
) -> None:
41+
import serializer.tosa_serializer as ts # type: ignore # noqa: F401
42+
43+
validate_num_inputs(self.target, inputs, 1)
44+
validate_same_dtype(self.target, [*inputs, output], ts)
45+
validate_valid_dtype(
46+
self.target,
47+
inputs[0],
48+
ts.DType.FP32,
49+
output.tosa_spec,
50+
)
51+
52+
self._serialize_operator(
53+
node, tosa_graph, ts.TosaOp.Op().CEIL, [inputs[0].name], [output.name]
54+
)

backends/arm/operators/op_floor.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 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+
from typing import Any, List
7+
8+
import torch.fx
9+
10+
from executorch.backends.arm.operators.node_visitor import (
11+
NodeVisitor,
12+
register_node_visitor,
13+
)
14+
from executorch.backends.arm.operators.operator_validation_utils import (
15+
validate_num_inputs,
16+
validate_same_dtype,
17+
validate_valid_dtype,
18+
)
19+
from executorch.backends.arm.tosa import TosaSpecification
20+
21+
from executorch.backends.arm.tosa.mapping import TosaArg
22+
23+
24+
@register_node_visitor
25+
class FloorVisitor(NodeVisitor):
26+
target = "aten.floor.default"
27+
28+
# INT case should be handled by op_table
29+
tosa_specs = [TosaSpecification.create_from_string("TOSA-1.0+FP")]
30+
31+
def __init__(self, *args):
32+
super().__init__(*args)
33+
34+
def define_node(
35+
self,
36+
node: torch.fx.Node,
37+
tosa_graph: Any,
38+
inputs: List[TosaArg],
39+
output: TosaArg,
40+
) -> None:
41+
import serializer.tosa_serializer as ts # type: ignore # noqa: F401
42+
43+
validate_num_inputs(self.target, inputs, 1)
44+
validate_same_dtype(self.target, [*inputs, output], ts)
45+
validate_valid_dtype(
46+
self.target,
47+
inputs[0],
48+
ts.DType.FP32,
49+
output.tosa_spec,
50+
)
51+
52+
self._serialize_operator(
53+
node, tosa_graph, ts.TosaOp.Op().FLOOR, [inputs[0].name], [output.name]
54+
)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright 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+
from typing import Any, List
7+
8+
import torch.fx
9+
10+
from executorch.backends.arm.operators.node_visitor import (
11+
NodeVisitor,
12+
register_node_visitor,
13+
)
14+
from executorch.backends.arm.operators.operator_validation_utils import (
15+
validate_num_inputs,
16+
validate_same_dtype,
17+
validate_valid_dtype,
18+
)
19+
from executorch.backends.arm.tosa import TosaSpecification
20+
from executorch.backends.arm.tosa.mapping import TosaArg
21+
22+
23+
@register_node_visitor
24+
class LogicalNotVisitor(NodeVisitor):
25+
target = "aten.logical_not.default"
26+
27+
tosa_specs = [
28+
TosaSpecification.create_from_string("TOSA-1.0+INT"),
29+
TosaSpecification.create_from_string("TOSA-1.0+FP"),
30+
]
31+
32+
def __init__(self, *args):
33+
super().__init__(*args)
34+
35+
def define_node(
36+
self,
37+
node: torch.fx.Node,
38+
tosa_graph: Any,
39+
inputs: List[TosaArg],
40+
output: TosaArg,
41+
) -> None:
42+
import serializer.tosa_serializer as ts # type: ignore # noqa: F401
43+
44+
validate_num_inputs(self.target, inputs, 1)
45+
validate_same_dtype(self.target, [*inputs, output], ts)
46+
validate_valid_dtype(
47+
self.target,
48+
[*inputs, output],
49+
[ts.DType.BOOL],
50+
output.tosa_spec,
51+
)
52+
53+
self._serialize_operator(
54+
node,
55+
tosa_graph,
56+
ts.TosaOp.Op().LOGICAL_NOT,
57+
[inputs[0].name],
58+
[output.name],
59+
)

backends/arm/operators/ops_unary.py

Lines changed: 0 additions & 68 deletions
This file was deleted.

backends/arm/test/misc/test_extract_io_params_tosa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from executorch.backends.arm.test.common import SkipIfNoModelConverter
1818
from executorch.backends.arm.tosa import TosaSpecification
1919
from executorch.backends.arm.tosa.partitioner import TOSAPartitioner
20-
from executorch.backends.arm.vgf_partitioner import VgfPartitioner
20+
from executorch.backends.arm.vgf import VgfPartitioner
2121
from executorch.exir import to_edge_transform_and_lower
2222
from executorch.exir.passes.quantize_io_pass import extract_io_quant_params
2323
from torchao.quantization.pt2e.quantize_pt2e import convert_pt2e, prepare_pt2e

backends/arm/test/tester/arm_tester.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
from executorch.backends.arm.tosa.partitioner import TOSAPartitioner
6464
from executorch.backends.arm.tosa.specification import get_tosa_spec
6565

66-
from executorch.backends.arm.vgf_partitioner import VgfPartitioner
66+
from executorch.backends.arm.vgf import VgfPartitioner
6767

6868
from executorch.backends.test.harness.stages import Stage, StageType
6969
from executorch.backends.xnnpack.test.tester import Tester

backends/arm/vgf/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 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+
8+
from .backend import VgfBackend # noqa: F401
9+
from .partitioner import VgfPartitioner # noqa: F401
10+
11+
__all__ = [
12+
"VgfBackend",
13+
"VgfPartitioner",
14+
]
File renamed without changes.

0 commit comments

Comments
 (0)