Skip to content

Commit 8a68c22

Browse files
committed
Update
[ghstack-poisoned]
2 parents 271d870 + 66799e3 commit 8a68c22

Some content is hidden

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

63 files changed

+874
-134
lines changed

.ci/scripts/wheel/envvar_windows.sh

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

.ci/scripts/wheel/pre_build_script.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ set -euxo pipefail
99

1010
# This script is run before building ExecuTorch binaries
1111

12-
# Enable long paths (relevant for Windows, but can run on any system).
13-
git config --system core.longpaths true
14-
1512
# Clone nested submodules for tokenizers - this is a workaround for recursive
1613
# submodule clone failing due to path length limitations on Windows. Eventually,
1714
# we should update the core job in test-infra to enable long paths before
@@ -25,4 +22,4 @@ popd
2522
# which does install them. Though we'd need to disable build isolation to be
2623
# able to see the installed torch package.
2724

28-
"${GITHUB_WORKSPACE}/${REPOSITORY}/install_requirements.sh" --example
25+
"${GITHUB_WORKSPACE}/${REPOSITORY}/install_requirements.sh" --example
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# This script runs the provided command from a symlinked version of the active
8+
# working directory, in order to minimize path lengths and work around long
9+
# path limitations on Windows.
10+
11+
set -x
12+
13+
PWSH_SCRIPT = "& {
14+
\$symlinkDir = Join-Path -Path \$env:GITHUB_WORKSPACE -ChildPath \"et-build\"
15+
New-Item -ItemType SymbolicLink -Path \$symlinkDir -Target $PWD
16+
Write-Host \$symlinkDir
17+
}"
18+
19+
SYMLINK_DIR=`powershell -Command "$PWSH_SCRIPT"`
20+
cd $SYMLINK_DIR
21+
$1 ${@:2}

.github/workflows/build-wheels-windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
matrix:
4444
include:
4545
- repository: pytorch/executorch
46+
env-script: .ci/scripts/wheel/run_with_symlink_windows.sh
4647
pre-script: .ci/scripts/wheel/pre_build_script.sh
4748
post-script: .ci/scripts/wheel/post_build_script.sh
4849
smoke-test-script: .ci/scripts/wheel/test_windows.py

backends/arm/arm_backend.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# backends. Converts via TOSA as an intermediate form supported by AoT and
1111
# JIT compiler flows.
1212
#
13+
from enum import Enum
1314
from typing import List, Optional
1415

1516
from executorch.backends.arm.tosa_specification import ( # type: ignore[import-not-found]
@@ -22,12 +23,16 @@
2223

2324

2425
class ArmCompileSpecBuilder:
26+
class DebugMode(Enum):
27+
JSON = 1
28+
2529
def __init__(self):
2630
self.compile_spec: List[CompileSpec] = []
2731
self.compiler_flags = []
2832
self.output_format = None
2933
self.path_for_intermediates = None
3034
self.tosa_spec = None
35+
self.tosa_debug_mode = None
3136

3237
def vgf_compile_spec(
3338
self,
@@ -163,6 +168,13 @@ def dump_intermediate_artifacts_to(
163168
self.path_for_intermediates = output_path
164169
return self
165170

171+
def dump_debug_info(self, debug_mode: DebugMode) -> "ArmCompileSpecBuilder":
172+
"""
173+
Dump debugging information into the intermediates path
174+
"""
175+
self.tosa_debug_mode = debug_mode.name
176+
return self
177+
166178
def build(self) -> List[CompileSpec]:
167179
"""
168180
Generate a list of compile spec objects from the builder
@@ -188,6 +200,16 @@ def build(self) -> List[CompileSpec]:
188200
CompileSpec("debug_artifact_path", self.path_for_intermediates.encode())
189201
)
190202

203+
if self.tosa_debug_mode is not None:
204+
if not self.path_for_intermediates:
205+
raise ValueError(
206+
"dump_debug_info() must be used in conjunction with dump_intermediate_artifacts_to()"
207+
)
208+
209+
self.compile_spec.append(
210+
CompileSpec("dump_debug_info", self.tosa_debug_mode.encode())
211+
)
212+
191213
return self.compile_spec
192214

193215

backends/arm/operators/node_visitor.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
# pyre-unsafe
77

8-
from typing import Any, Dict, List
8+
from typing import Any, Dict, List, Optional
99

1010
import torch
1111

12+
from executorch.backends.arm.debug.schema import DebugHook
1213
from executorch.backends.arm.tosa_mapping import TosaArg
1314
from executorch.backends.arm.tosa_specification import TosaSpecification
1415
from torch.export import ExportedProgram
@@ -29,9 +30,38 @@ class NodeVisitor:
2930
TosaSpecification.create_from_string("TOSA-1.0+FP"),
3031
]
3132

32-
def __init__(self, exported_program: ExportedProgram, tosa_spec: TosaSpecification):
33+
def __init__(
34+
self,
35+
exported_program: ExportedProgram,
36+
tosa_spec: TosaSpecification,
37+
debug_hook: Optional[DebugHook] = None,
38+
):
3339
self._exported_program = exported_program
3440
self.tosa_spec = tosa_spec
41+
self.debug_hook = debug_hook
42+
43+
def _serialize_operator(
44+
self,
45+
node: torch.fx.Node,
46+
tosa_graph: Any,
47+
tosa_op: Any,
48+
inputs: List[str],
49+
outputs: List[str],
50+
attributes: Optional[Any] = None,
51+
) -> None:
52+
tosa_graph.addOperator(
53+
tosa_op,
54+
inputs=inputs,
55+
outputs=outputs,
56+
attributes=attributes,
57+
)
58+
59+
if self.debug_hook:
60+
self.debug_hook.add(
61+
node,
62+
tosa_op=outputs[0],
63+
tosa_op_id=tosa_op,
64+
)
3565

3666
def define_node(
3767
self,

backends/arm/operators/op_abs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ def define_node(
123123
)
124124

125125
# MI lowering
126-
tosa_graph.addOperator(
126+
self._serialize_operator(
127+
node,
128+
tosa_graph,
127129
ts.TosaOp.Op().ABS,
128130
[inputs[0].name],
129131
[output.name],

backends/arm/operators/op_add.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def define_node(
7373
input1, input2 = rescaled_inputs
7474

7575
# Do the INT32 Add
76-
tosa_graph.addOperator(
76+
self._serialize_operator(
77+
node,
78+
tosa_graph,
7779
ts.TosaOp.Op().ADD,
7880
[input1.name, input2.name],
7981
[add_output.name],
@@ -127,7 +129,9 @@ def define_node(
127129
input1, input2 = inputs
128130

129131
# FP lowering
130-
tosa_graph.addOperator(
132+
self._serialize_operator(
133+
node,
134+
tosa_graph,
131135
ts.TosaOp.Op().ADD,
132136
[input1.name, input2.name],
133137
[output.name],

backends/arm/operators/op_amax.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ def define_node(
6161

6262
attr = ts.TosaSerializerAttribute()
6363
attr.ReduceMaxAttribute(axis=input.dim_order.index(dim), nan_mode=1)
64-
tosa_graph.addOperator(
65-
ts.TosaOp.Op().REDUCE_MAX, [input.name], [output.name], attr
64+
self._serialize_operator(
65+
node,
66+
tosa_graph,
67+
ts.TosaOp.Op().REDUCE_MAX,
68+
[input.name],
69+
[output.name],
70+
attr,
6671
)

backends/arm/operators/op_amin.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ def define_node(
6161

6262
attr = ts.TosaSerializerAttribute()
6363
attr.ReduceMinAttribute(axis=input.dim_order.index(dim), nan_mode=1)
64-
tosa_graph.addOperator(
65-
ts.TosaOp.Op().REDUCE_MIN, [input.name], [output.name], attr
64+
self._serialize_operator(
65+
node,
66+
tosa_graph,
67+
ts.TosaOp.Op().REDUCE_MIN,
68+
[input.name],
69+
[output.name],
70+
attr,
6671
)

0 commit comments

Comments
 (0)