Skip to content
Closed
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
234 changes: 139 additions & 95 deletions codegen/tools/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def define_common_targets(is_fbcode = False):
deps = [
":gen_oplist_lib",
],
preload_deps = [] if runtime.is_oss else ["//executorch/codegen/tools:selective_build"], # TODO(larryliu0820) :selective_build doesn't build in OSS yet
preload_deps = ["//executorch/codegen/tools:selective_build"],
package_style = "inplace",
visibility = [
"//executorch/...",
Expand All @@ -43,15 +43,25 @@ def define_common_targets(is_fbcode = False):
srcs = ["yaml_util.py"],
)

runtime.python_library(
name = "merge_yaml_lib",
srcs = ["merge_yaml.py"],
base_module = "executorch.codegen.tools",
deps = [
":yaml_util",
],
external_deps = ["torchgen"],
)
if not runtime.is_oss and is_fbcode:
runtime.python_library(
name = "merge_yaml_lib",
srcs = ["merge_yaml.py"],
base_module = "executorch.codegen.tools",
deps = [
":yaml_util",
],
external_deps = ["torchgen"],
)
else:
runtime.python_library(
name = "merge_yaml_lib",
srcs = ["merge_yaml.py"],
base_module = "executorch.codegen.tools",
deps = [
":yaml_util",
],
)

runtime.python_binary(
name = "merge_yaml",
Expand All @@ -64,31 +74,43 @@ def define_common_targets(is_fbcode = False):
visibility = ["PUBLIC"],
)

runtime.python_test(
name = "test_gen_oplist",
base_module = "",
srcs = [
"test/test_gen_oplist.py",
],
deps = [
":gen_oplist_lib",
],
package_style = "inplace",
visibility = [
"//executorch/...",
"@EXECUTORCH_CLIENTS",
],
)
if not runtime.is_oss and is_fbcode:
runtime.python_test(
name = "test_gen_oplist",
base_module = "",
srcs = [
"test/test_gen_oplist.py",
],
deps = [
":gen_oplist_lib",
],
external_deps = ["torchgen"],
package_style = "inplace",
visibility = [
"//executorch/...",
"@EXECUTORCH_CLIENTS",
],
)

runtime.python_library(
name = "gen_all_oplist_lib",
srcs = ["gen_all_oplist.py"],
base_module = "executorch.codegen.tools",
visibility = [
"//executorch/...",
],
external_deps = ["torchgen"],
)
if not runtime.is_oss and is_fbcode:
runtime.python_library(
name = "gen_all_oplist_lib",
srcs = ["gen_all_oplist.py"],
base_module = "executorch.codegen.tools",
visibility = [
"//executorch/...",
],
external_deps = ["torchgen"],
)
else:
runtime.python_library(
name = "gen_all_oplist_lib",
srcs = ["gen_all_oplist.py"],
base_module = "executorch.codegen.tools",
visibility = [
"//executorch/...",
],
)

runtime.python_binary(
name = "gen_all_oplist",
Expand Down Expand Up @@ -123,20 +145,22 @@ def define_common_targets(is_fbcode = False):
_is_external_target = True,
)

runtime.python_test(
name = "test_gen_all_oplist",
srcs = [
"test/test_gen_all_oplist.py",
],
package_style = "inplace",
visibility = [
"PUBLIC",
],
deps = [
":gen_all_oplist_lib",
],
_is_external_target = True,
)
if not runtime.is_oss and is_fbcode:
runtime.python_test(
name = "test_gen_all_oplist",
srcs = [
"test/test_gen_all_oplist.py",
],
package_style = "inplace",
visibility = [
"PUBLIC",
],
deps = [
":gen_all_oplist_lib",
],
external_deps = ["torchgen"],
_is_external_target = True,
)

runtime.python_library(
name = "gen_selected_op_variants_lib",
Expand All @@ -159,29 +183,38 @@ def define_common_targets(is_fbcode = False):
_is_external_target = True,
)

runtime.python_test(
name = "test_gen_selected_op_variants",
srcs = [
"test/test_gen_selected_op_variants.py",
],
package_style = "inplace",
visibility = [
"PUBLIC",
],
deps = [
":gen_selected_op_variants_lib",
"fbsource//third-party/pypi/expecttest:expecttest",
],
_is_external_target = True,
)
if not runtime.is_oss and is_fbcode:
runtime.python_test(
name = "test_gen_selected_op_variants",
srcs = [
"test/test_gen_selected_op_variants.py",
],
package_style = "inplace",
visibility = [
"PUBLIC",
],
deps = [
":gen_selected_op_variants_lib",
"fbsource//third-party/pypi/expecttest:expecttest",
],
_is_external_target = True,
)

runtime.python_library(
name = "gen_selected_prim_ops_lib",
srcs = ["gen_selected_prim_ops.py"],
base_module = "executorch.codegen.tools",
visibility = ["//executorch/..."],
external_deps = ["torchgen"],
)
if not runtime.is_oss and is_fbcode:
runtime.python_library(
name = "gen_selected_prim_ops_lib",
srcs = ["gen_selected_prim_ops.py"],
base_module = "executorch.codegen.tools",
visibility = ["//executorch/..."],
external_deps = ["torchgen"],
)
else:
runtime.python_library(
name = "gen_selected_prim_ops_lib",
srcs = ["gen_selected_prim_ops.py"],
base_module = "executorch.codegen.tools",
visibility = ["//executorch/..."],
)

runtime.python_binary(
name = "gen_selected_prim_ops",
Expand All @@ -196,46 +229,57 @@ def define_common_targets(is_fbcode = False):
_is_external_target = True,
)

if not runtime.is_oss:
runtime.cxx_python_extension(
name = "selective_build",
srcs = [
"selective_build.cpp",
],

runtime.cxx_python_extension(
name = "selective_build",
srcs = [
"selective_build.cpp",
],
base_module = "executorch.codegen.tools",
types = ["selective_build.pyi"],
preprocessor_flags = [
"-DEXECUTORCH_PYTHON_MODULE_NAME=selective_build",
],
deps = [
"//executorch/runtime/core:core",
"//executorch/schema:program",
],
external_deps = [
"pybind11",
],
use_static_deps = True,
visibility = ["//executorch/codegen/..."],
)


# TODO(larryliu0820): This is a hack to only run these on fbcode. These targets depend on exir which is only available in fbcode.
if not runtime.is_oss and is_fbcode:
runtime.python_library(
name = "gen_ops_def_lib",
srcs = ["gen_ops_def.py"],
base_module = "executorch.codegen.tools",
types = ["selective_build.pyi"],
preprocessor_flags = [
"-DEXECUTORCH_PYTHON_MODULE_NAME=selective_build",
visibility = [
"//executorch/...",
],
deps = [
"//executorch/runtime/core:core",
"//executorch/schema:program",
],
external_deps = [
"pybind11",
"fbsource//third-party/pypi/pyyaml:pyyaml",
":yaml_util",
"//caffe2:torch",
"//executorch/exir:schema",
"//executorch/exir/_serialize:lib",
],
use_static_deps = True,
visibility = ["//executorch/codegen/..."],
)


# TODO(larryliu0820): This is a hack to only run these two on fbcode. These targets depends on exir which is only available in fbcode.
if not runtime.is_oss and is_fbcode:
runtime.python_binary(
name = "gen_functions_yaml",
srcs = ["gen_ops_def.py"],
main_module = "executorch.codegen.tools.gen_ops_def",
package_style = "inplace",
visibility = [
"//executorch/...",
"@EXECUTORCH_CLIENTS",
],
deps = [
"fbsource//third-party/pypi/pyyaml:pyyaml",
":yaml_util",
"//caffe2:torch",
"//executorch/exir:schema",
"//executorch/exir/_serialize:lib",
":gen_ops_def_lib",
],
)

Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ addopts =

# codegen
codegen/test
codegen/tools

# devtools
devtools/
Expand Down
Loading