Skip to content

Commit 3414c7d

Browse files
committed
Merge remote-tracking branch 'origin/main' into export-D57463419
2 parents b162d19 + 3807045 commit 3414c7d

File tree

115 files changed

+2741
-1415
lines changed

Some content is hidden

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

115 files changed

+2741
-1415
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
48b6c8dbc376db4406a979b35cd6909bcb428931
1+
c017c97333dfb9d17f2e5357980241827e50e8d5

.github/scripts/cherry_pick.py

Lines changed: 103 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import json
99
import os
1010
import re
11-
from typing import Any, Optional
11+
from typing import Any, cast, Dict, List, Optional
1212

1313
from urllib.error import HTTPError
1414

15-
from github_utils import gh_fetch_url, gh_post_pr_comment
15+
from github_utils import gh_fetch_url, gh_post_pr_comment, gh_query_issues_by_labels
1616

1717
from gitutils import get_git_remote_name, get_git_repo_dir, GitRepo
1818
from trymerge import get_pr_commit_sha, GitHubPR
@@ -24,6 +24,7 @@
2424
"critical",
2525
"fixnewfeature",
2626
}
27+
RELEASE_BRANCH_REGEX = re.compile(r"release/(?P<version>.+)")
2728

2829

2930
def parse_args() -> Any:
@@ -34,7 +35,7 @@ def parse_args() -> Any:
3435
"--onto-branch", type=str, required=True, help="the target release branch"
3536
)
3637
parser.add_argument(
37-
"--github-actor", type=str, required=True, help="all the worlds a stage"
38+
"--github-actor", type=str, required=True, help="all the world's a stage"
3839
)
3940
parser.add_argument(
4041
"--classification",
@@ -63,6 +64,33 @@ def get_merge_commit_sha(repo: GitRepo, pr: GitHubPR) -> Optional[str]:
6364
return commit_sha if pr.is_closed() else None
6465

6566

67+
def get_release_version(onto_branch: str) -> Optional[str]:
68+
"""
69+
Return the release version if the target branch is a release branch
70+
"""
71+
m = re.match(RELEASE_BRANCH_REGEX, onto_branch)
72+
return m.group("version") if m else ""
73+
74+
75+
def get_tracker_issues(
76+
org: str, project: str, onto_branch: str
77+
) -> List[Dict[str, Any]]:
78+
"""
79+
Find the tracker issue from the repo. The tracker issue needs to have the title
80+
like [VERSION] Release Tracker following the convention on PyTorch
81+
"""
82+
version = get_release_version(onto_branch)
83+
if not version:
84+
return []
85+
86+
tracker_issues = gh_query_issues_by_labels(org, project, labels=["release tracker"])
87+
if not tracker_issues:
88+
return []
89+
90+
# Figure out the tracker issue from the list by looking at the title
91+
return [issue for issue in tracker_issues if version in issue.get("title", "")]
92+
93+
6694
def cherry_pick(
6795
github_actor: str,
6896
repo: GitRepo,
@@ -82,17 +110,49 @@ def cherry_pick(
82110
)
83111

84112
try:
113+
org, project = repo.gh_owner_and_name()
114+
115+
cherry_pick_pr = ""
85116
if not dry_run:
86-
org, project = repo.gh_owner_and_name()
87117
cherry_pick_pr = submit_pr(repo, pr, cherry_pick_branch, onto_branch)
88118

89-
msg = f"The cherry pick PR is at {cherry_pick_pr}"
90-
if fixes:
91-
msg += f" and it is linked with issue {fixes}"
92-
elif classification in REQUIRES_ISSUE:
93-
msg += f" and it is recommended to link a {classification} cherry pick PR with an issue"
119+
tracker_issues_comments = []
120+
tracker_issues = get_tracker_issues(org, project, onto_branch)
121+
for issue in tracker_issues:
122+
issue_number = int(str(issue.get("number", "0")))
123+
if not issue_number:
124+
continue
125+
126+
res = cast(
127+
Dict[str, Any],
128+
post_tracker_issue_comment(
129+
org,
130+
project,
131+
issue_number,
132+
pr.pr_num,
133+
cherry_pick_pr,
134+
classification,
135+
fixes,
136+
dry_run,
137+
),
138+
)
139+
140+
comment_url = res.get("html_url", "")
141+
if comment_url:
142+
tracker_issues_comments.append(comment_url)
94143

95-
post_comment(org, project, pr.pr_num, msg)
144+
msg = f"The cherry pick PR is at {cherry_pick_pr}"
145+
if fixes:
146+
msg += f" and it is linked with issue {fixes}."
147+
elif classification in REQUIRES_ISSUE:
148+
msg += f" and it is recommended to link a {classification} cherry pick PR with an issue."
149+
150+
if tracker_issues_comments:
151+
msg += " The following tracker issues are updated:\n"
152+
for tracker_issues_comment in tracker_issues_comments:
153+
msg += f"* {tracker_issues_comment}\n"
154+
155+
post_pr_comment(org, project, pr.pr_num, msg, dry_run)
96156

97157
finally:
98158
if current_branch:
@@ -164,7 +224,9 @@ def submit_pr(
164224
raise RuntimeError(msg) from error
165225

166226

167-
def post_comment(org: str, project: str, pr_num: int, msg: str) -> None:
227+
def post_pr_comment(
228+
org: str, project: str, pr_num: int, msg: str, dry_run: bool = False
229+
) -> List[Dict[str, Any]]:
168230
"""
169231
Post a comment on the PR itself to point to the cherry picking PR when success
170232
or print the error when failure
@@ -187,7 +249,35 @@ def post_comment(org: str, project: str, pr_num: int, msg: str) -> None:
187249
comment = "\n".join(
188250
(f"### Cherry picking #{pr_num}", f"{msg}", "", f"{internal_debugging}")
189251
)
190-
gh_post_pr_comment(org, project, pr_num, comment)
252+
return gh_post_pr_comment(org, project, pr_num, comment, dry_run)
253+
254+
255+
def post_tracker_issue_comment(
256+
org: str,
257+
project: str,
258+
issue_num: int,
259+
pr_num: int,
260+
cherry_pick_pr: str,
261+
classification: str,
262+
fixes: str,
263+
dry_run: bool = False,
264+
) -> List[Dict[str, Any]]:
265+
"""
266+
Post a comment on the tracker issue (if any) to record the cherry pick
267+
"""
268+
comment = "\n".join(
269+
(
270+
"Link to landed trunk PR (if applicable):",
271+
f"* https://github.com/{org}/{project}/pull/{pr_num}",
272+
"",
273+
"Link to release branch PR:",
274+
f"* {cherry_pick_pr}",
275+
"",
276+
"Criteria Category:",
277+
" - ".join((classification.capitalize(), fixes.capitalize())),
278+
)
279+
)
280+
return gh_post_pr_comment(org, project, issue_num, comment, dry_run)
191281

192282

193283
def main() -> None:
@@ -219,7 +309,7 @@ def main() -> None:
219309

220310
except RuntimeError as error:
221311
if not args.dry_run:
222-
post_comment(org, project, pr_num, str(error))
312+
post_pr_comment(org, project, pr_num, str(error))
223313
else:
224314
raise error
225315

.github/scripts/github_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,12 @@ def gh_update_pr_state(org: str, repo: str, pr_num: int, state: str = "open") ->
208208
)
209209
else:
210210
raise
211+
212+
213+
def gh_query_issues_by_labels(
214+
org: str, repo: str, labels: List[str], state: str = "open"
215+
) -> List[Dict[str, Any]]:
216+
url = f"{GITHUB_API_URL}/repos/{org}/{repo}/issues"
217+
return gh_fetch_json(
218+
url, method="GET", params={"labels": ",".join(labels), "state": state}
219+
)

.github/workflows/trunk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
sudo sysctl fs.inotify.max_user_watches=1048576 # 1024 * 1024
153153
154154
# Test ethos-u delegate examples with run.sh
155-
PYTHON_EXECUTABLE=python bash examples/arm/run.sh examples/arm/ethos-u-scratch/ buck2
155+
PYTHON_EXECUTABLE=python bash examples/arm/run.sh examples/arm/ethos-u-scratch/
156156
157157
test-arm-reference-delegation:
158158
name: test-arm-reference-delegation

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@
6464
[submodule "third-party/ios-cmake"]
6565
path = third-party/ios-cmake
6666
url = https://github.com/leetal/ios-cmake
67+
[submodule "examples/models/phi-3-mini/third-party/sentencepiece"]
68+
path = examples/models/phi-3-mini/third-party/sentencepiece
69+
url = https://github.com/google/sentencepiece.git

backends/arm/operators/op_avg_pool2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
NodeVisitor,
1111
register_node_visitor,
1212
)
13-
from executorch.backends.arm.operators.op_common import build_avg_pool_2d_common
1413
from executorch.backends.arm.tosa_mapping import TosaArg
14+
from executorch.backends.arm.tosa_utils import build_avg_pool_2d_common
1515

1616

1717
@register_node_visitor

backends/arm/operators/op_common.py

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

backends/arm/operators/op_mean_dim.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
NodeVisitor,
1111
register_node_visitor,
1212
)
13-
from executorch.backends.arm.operators.op_common import build_avg_pool_2d_common
1413
from executorch.backends.arm.tosa_mapping import TosaArg
14+
from executorch.backends.arm.tosa_utils import build_avg_pool_2d_common
1515

1616

1717
@register_node_visitor

backends/arm/test/models/test_mobilenet_v2_arm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_mv2_tosa_MI(self):
6060
.check(list(self.all_operators))
6161
.partition()
6262
.to_executorch()
63-
.run_method_and_compare_outputs()
63+
.run_method_and_compare_outputs(inputs=self.model_inputs)
6464
)
6565

6666
def test_mv2_tosa_BI(self):

backends/arm/test/ops/test_add.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _test_add_tosa_MI_pipeline(
7171
.partition()
7272
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
7373
.to_executorch()
74-
.run_method_and_compare_outputs()
74+
.run_method_and_compare_outputs(inputs=test_data)
7575
)
7676

7777
def _test_add_tosa_BI_pipeline(
@@ -91,7 +91,7 @@ def _test_add_tosa_BI_pipeline(
9191
.partition()
9292
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
9393
.to_executorch()
94-
.run_method_and_compare_outputs(qtol=1)
94+
.run_method_and_compare_outputs(inputs=test_data, qtol=1)
9595
)
9696

9797
def _test_add_u55_BI_pipeline(

0 commit comments

Comments
 (0)