Skip to content

Commit 93e7137

Browse files
Merge remote-tracking branch 'executorch/main' into HEAD
Change-Id: I75e1363bce9f6ad814d8c7fe7e45f3884ddc1cb4
2 parents 5a961d4 + 0fb2ccf commit 93e7137

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+220
-169
lines changed

backends/arm/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ The Arm Backend should be considered a prototype quality at this point, likely s
104104
## Current flows
105105

106106
The ArmBackend has a two stage process,
107-
- Compile to TOSA to rationalise the graph into known hardware support profiles. Currently this is to v0.80.0 TOSA BI with specific concern to a subset which gives support on Ethos-U55, the target of the initial prototype efforts.
108-
- Lower via the ethos-u-vela compilation flow which takes TOSA v0.80.0 as an input and produces a low level commandstream for the hardware which is then passed via the delegate to the ethos-u-core-driver for direct execution.
107+
- Compile to TOSA to rationalise the graph into known hardware support profiles. Currently this is to v0.80 TOSA BI with specific concern to a subset which gives support on Ethos-U55, the target of the initial prototype efforts.
108+
- Lower via the ethos-u-vela compilation flow which takes TOSA v0.80 as an input and produces a low level commandstream for the hardware which is then passed via the delegate to the ethos-u-core-driver for direct execution.
109109

110110
The ArmPartitioner is currenly used to ensure the operations converted are Ethos-U compatible, but will be extended to offer spec-correct TOSA Base inference and TOSA Main Inference generation in future.
111111

backends/arm/arm_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def ethosu_compile_spec(
9090
if extra_flags is not None:
9191
self.compiler_flags.append(extra_flags)
9292

93-
base_tosa_version = "TOSA-0.80.0+BI"
93+
base_tosa_version = "TOSA-0.80+BI"
9494
if "u55" in config:
9595
# Add the Ethos-U55 extension marker
9696
base_tosa_version += "+u55"

backends/arm/operator_support/right_shift_support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class RightShiftSupported(SupportedTOSAOperatorCheck):
2323
targets = [exir_ops.edge.aten.__rshift__.Scalar]
2424

2525
tosa_specs = [
26-
TosaSpecification.create_from_string("TOSA-0.80.0+BI"),
27-
TosaSpecification.create_from_string("TOSA-0.80.0+MI"),
26+
TosaSpecification.create_from_string("TOSA-0.80+BI"),
27+
TosaSpecification.create_from_string("TOSA-0.80+MI"),
2828
]
2929

3030
def is_node_supported(self, node: fx.Node, tosa_spec: TosaSpecification):

backends/arm/operator_support/to_copy_support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class ToCopySupported(SupportedTOSAOperatorCheck):
2525
targets = [exir_ops.edge.aten._to_copy.default]
2626

2727
tosa_specs = [
28-
TosaSpecification.create_from_string("TOSA-0.80.0+BI"),
29-
TosaSpecification.create_from_string("TOSA-0.80.0+MI"),
28+
TosaSpecification.create_from_string("TOSA-0.80+BI"),
29+
TosaSpecification.create_from_string("TOSA-0.80+MI"),
3030
]
3131

3232
SupportedTypeDict = dict[torch.dtype, list[torch.dtype]]

backends/arm/operator_support/tosa_supported_operators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def is_node_supported(self, node: fx.Node, tosa_spec: TosaSpecification) -> bool
3535
_tosa_spec_dicts: dict[
3636
TosaSpecification, dict[str, Type[SupportedTOSAOperatorCheck]]
3737
] = {
38-
TosaSpecification.create_from_string("TOSA-0.80.0+BI"): {},
39-
TosaSpecification.create_from_string("TOSA-0.80.0+MI"): {},
38+
TosaSpecification.create_from_string("TOSA-0.80+BI"): {},
39+
TosaSpecification.create_from_string("TOSA-0.80+MI"): {},
4040
}
4141

4242

backends/arm/operators/node_visitor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class NodeVisitor:
2525
# When all node_visitors has been refactored to target a specific
2626
# version, this list should be removed.
2727
tosa_specs = [
28-
TosaSpecification.create_from_string("TOSA-0.80.0+BI"),
29-
TosaSpecification.create_from_string("TOSA-0.80.0+MI"),
28+
TosaSpecification.create_from_string("TOSA-0.80+BI"),
29+
TosaSpecification.create_from_string("TOSA-0.80+MI"),
3030
]
3131

3232
def __init__(self, exported_program: ExportedProgram, tosa_spec: TosaSpecification):
@@ -45,8 +45,8 @@ def define_node(
4545

4646
# container for all node visitors
4747
_node_visitor_dicts = {
48-
TosaSpecification.create_from_string("TOSA-0.80.0+BI"): {},
49-
TosaSpecification.create_from_string("TOSA-0.80.0+MI"): {},
48+
TosaSpecification.create_from_string("TOSA-0.80+BI"): {},
49+
TosaSpecification.create_from_string("TOSA-0.80+MI"): {},
5050
}
5151

5252

backends/arm/operators/op_add.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AddVisitor_080_BI(NodeVisitor):
2626
target = "aten.add.Tensor"
2727

2828
tosa_specs = [
29-
TosaSpecification.create_from_string("TOSA-0.80.0+BI"),
29+
TosaSpecification.create_from_string("TOSA-0.80+BI"),
3030
]
3131

3232
def __init__(self, *args):
@@ -39,7 +39,7 @@ def define_node(
3939
inputs: List[TosaArg],
4040
output: TosaArg,
4141
) -> None:
42-
# Specification (0.80.0) states that input and output types
42+
# Specification (0.80) states that input and output types
4343
# should all be the same
4444
assert inputs[0].dtype == inputs[1].dtype == output.dtype
4545
# Handle int8 (quantized) and int32
@@ -83,7 +83,7 @@ class AddVisitor_080_MI(AddVisitor_080_BI):
8383
# inheriting 'target' from BI class
8484

8585
tosa_specs = [
86-
TosaSpecification.create_from_string("TOSA-0.80.0+MI"),
86+
TosaSpecification.create_from_string("TOSA-0.80+MI"),
8787
]
8888

8989
def __init__(self, *args):
@@ -96,7 +96,7 @@ def define_node(
9696
inputs: List[TosaArg],
9797
output: TosaArg,
9898
) -> None:
99-
# Specification (0.80.0) states that input and output types
99+
# Specification (0.80) states that input and output types
100100
# should all be the same
101101
assert inputs[0].dtype == inputs[1].dtype == output.dtype
102102

backends/arm/operators/op_avg_pool2d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AvgPool2dVisitor_0_80_BI(NodeVisitor):
2525
target = "aten.avg_pool2d.default"
2626

2727
tosa_specs = [
28-
TosaSpecification.create_from_string("TOSA-0.80.0+BI"),
28+
TosaSpecification.create_from_string("TOSA-0.80+BI"),
2929
]
3030

3131
def __init__(self, *args):
@@ -95,7 +95,7 @@ class AvgPool2dVisitor_0_80_MI(AvgPool2dVisitor_0_80_BI):
9595
# inheriting 'target' from BI class
9696

9797
tosa_specs = [
98-
TosaSpecification.create_from_string("TOSA-0.80.0+MI"),
98+
TosaSpecification.create_from_string("TOSA-0.80+MI"),
9999
]
100100

101101
def define_node(

backends/arm/operators/op_batch_norm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class BatchNormVisitor(NodeVisitor):
2323
target = "aten._native_batch_norm_legit_no_training.default"
2424

2525
tosa_specs = [
26-
TosaSpecification.create_from_string("TOSA-0.80.0+MI"),
26+
TosaSpecification.create_from_string("TOSA-0.80+MI"),
2727
]
2828

2929
def __init__(self, *args):

backends/arm/operators/op_div.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2023-2024 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 List
8+
9+
import serializer.tosa_serializer as ts
10+
import torch
11+
from executorch.backends.arm.operators.node_visitor import (
12+
NodeVisitor,
13+
register_node_visitor,
14+
)
15+
from executorch.backends.arm.tosa_mapping import TosaArg
16+
from executorch.backends.arm.tosa_specification import TosaSpecification
17+
from executorch.backends.arm.tosa_utils import tosa_shape
18+
from serializer.tosa_serializer import TosaOp
19+
20+
21+
@register_node_visitor
22+
class DivVisitor(NodeVisitor):
23+
target = "aten.div.Tensor"
24+
25+
# Only supported for MI
26+
tosa_specs = [
27+
TosaSpecification.create_from_string("TOSA-0.80+MI"),
28+
]
29+
30+
def __init__(self, *args):
31+
super().__init__(*args)
32+
33+
def define_node(
34+
self,
35+
node: torch.fx.Node,
36+
tosa_graph: ts.TosaSerializer,
37+
inputs: List[TosaArg],
38+
output: TosaArg,
39+
is_quant_node: bool,
40+
) -> None:
41+
# FP32 Div is implemented as output=x/y -> output=x*1/y e.g. MUL(x,RECIPROCAL(y))
42+
recip = tosa_graph.addIntermediate(
43+
tosa_shape(inputs[1].shape, inputs[1].dim_order), inputs[1].dtype
44+
)
45+
tosa_graph.addOperator(TosaOp.Op().RECIPROCAL, [inputs[1].name], [recip.name])
46+
47+
attr = ts.TosaSerializerAttribute()
48+
attr.MulAttribute(0)
49+
tosa_graph.addOperator(
50+
TosaOp.Op().MUL, [inputs[0].name, recip.name], [output.name], attr
51+
)

0 commit comments

Comments
 (0)