Skip to content

Commit e4bd8ad

Browse files
larryliu0820facebook-github-bot
authored andcommitted
Migrate gen_oplist.py to use executorch/codegen instead of pytorch torchgen (#11104)
Summary: As titled, after #10939 we are able to use `executorch.codegen` APIs instead of `torchgen.executorch` APIs. This PR moves `gen_oplist.py` to use the new `executorch.codgen` API. Reviewed By: kirklandsign Differential Revision: D75307480 Pulled By: larryliu0820
1 parent 05383fe commit e4bd8ad

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

codegen/parse.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55

66
import yaml
77

8-
from executorch.codegen.model import ETKernelIndex, ETKernelKey
8+
try:
9+
from executorch.codegen.model import ETKernelIndex, ETKernelKey
10+
except ImportError:
11+
# If we build from source, executorch.codegen is not available.
12+
# We can use relative import instead.
13+
from .model import ETKernelIndex, ETKernelKey # type: ignore[assignment]
914
from torchgen.gen import LineLoader, parse_native_yaml
1015
from torchgen.model import (
1116
BackendMetadata,

codegen/tools/gen_oplist.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
from typing import Any, Dict, List, Optional, Set
1313

1414
import yaml
15-
from torchgen.executorch.parse import strip_et_fields
15+
16+
try:
17+
from executorch.codegen.parse import strip_et_fields
18+
except ImportError:
19+
# If we build from source, executorch.codegen is not available.
20+
# We can use relative import instead.
21+
from ..parse import strip_et_fields
1622

1723
from torchgen.gen import LineLoader, parse_native_yaml_struct
1824
from torchgen.selective_build.operator import SelectiveBuildOperator

codegen/tools/targets.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ def define_common_targets(is_fbcode = False):
1515
visibility = [
1616
"//executorch/...",
1717
],
18-
external_deps = ["torchgen"],
19-
deps = select({
18+
deps = [
19+
"//executorch/codegen:gen_lib",
20+
] + select({
2021
"DEFAULT": [],
2122
"ovr_config//os:linux": [] if runtime.is_oss else ["//executorch/codegen/tools/fb:selective_build"], # TODO(larryliu0820) :selective_build doesn't build in OSS yet
2223
}),

install_requirements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def python_is_compatible():
7171
#
7272
# NOTE: If you're changing, make the corresponding change in .ci/docker/ci_commit_pins/pytorch.txt
7373
# by picking the hash from the same date in https://hud.pytorch.org/hud/pytorch/pytorch/nightly/
74-
NIGHTLY_VERSION = "dev20250325"
74+
NIGHTLY_VERSION = "dev20250524"
7575

7676

7777
def install_requirements(use_pytorch_nightly):

0 commit comments

Comments
 (0)