Skip to content

Migrate gen_oplist.py to use executorch/codegen instead of pytorch torchgen #11104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion codegen/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

import yaml

from executorch.codegen.model import ETKernelIndex, ETKernelKey
try:
from executorch.codegen.model import ETKernelIndex, ETKernelKey
except ImportError:
# If we build from source, executorch.codegen is not available.
# We can use relative import instead.
from .model import ETKernelIndex, ETKernelKey # type: ignore[assignment]
from torchgen.gen import LineLoader, parse_native_yaml
from torchgen.model import (
BackendMetadata,
Expand Down
8 changes: 7 additions & 1 deletion codegen/tools/gen_oplist.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
from typing import Any, Dict, List, Optional, Set

import yaml
from torchgen.executorch.parse import strip_et_fields

try:
from executorch.codegen.parse import strip_et_fields
except ImportError:
# If we build from source, executorch.codegen is not available.
# We can use relative import instead.
from ..parse import strip_et_fields

from torchgen.gen import LineLoader, parse_native_yaml_struct
from torchgen.selective_build.operator import SelectiveBuildOperator
Expand Down
5 changes: 3 additions & 2 deletions codegen/tools/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ def define_common_targets(is_fbcode = False):
visibility = [
"//executorch/...",
],
external_deps = ["torchgen"],
deps = select({
deps = [
"//executorch/codegen:gen_lib",
] + select({
"DEFAULT": [],
"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
}),
Expand Down
2 changes: 1 addition & 1 deletion install_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def python_is_compatible():
#
# NOTE: If you're changing, make the corresponding change in .ci/docker/ci_commit_pins/pytorch.txt
# by picking the hash from the same date in https://hud.pytorch.org/hud/pytorch/pytorch/nightly/
NIGHTLY_VERSION = "dev20250325"
NIGHTLY_VERSION = "dev20250524"


def install_requirements(use_pytorch_nightly):
Expand Down
Loading