Skip to content

Commit

Permalink
switch Bazel to the shared generate-code genrule (pytorch#75790)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#75790

We were building it before, but now we use it in downstream
rules. This enables us to eliminate the handwritten genrule.
ghstack-source-id: 155300051

Test Plan: Verified locally and in CI.

Reviewed By: dreiss

Differential Revision: D35645390

fbshipit-source-id: 478bb37a6ec295c232f66383babf46606e83ed5e
(cherry picked from commit 2822d4c)
  • Loading branch information
mikey dagitses authored and pytorchmergebot committed May 4, 2022
1 parent 096ff0e commit ac45fb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
22 changes: 2 additions & 20 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -148,33 +148,15 @@ libtorch_python_generated_sources = [
"torch/csrc/autograd/generated/python_return_types.cpp",
]

genrule(
name = "all_generated_code",
srcs = [
"aten/src/ATen/native/native_functions.yaml",
"aten/src/ATen/native/tags.yaml",
"aten/src/ATen/native/ts_native_functions.yaml",
"torch/csrc/lazy/core/shape_inference.h",
"torch/csrc/lazy/ts_backend/ts_native_functions.cpp",
"aten/src/ATen/templates/DispatchKeyNativeFunctions.cpp",
"aten/src/ATen/templates/DispatchKeyNativeFunctions.h",
"aten/src/ATen/templates/RegisterDispatchKey.cpp",
"aten/src/ATen/templates/LazyIr.h",
],
outs = libtorch_cpp_generated_sources + libtorch_python_generated_sources,
cmd = "$(location //tools/setup_helpers:generate_code) --install_dir `dirname $(location torch/csrc/autograd/generated/variable_factories.h)`/../.. --native-functions-path $(location aten/src/ATen/native/native_functions.yaml) --tags-path $(location aten/src/ATen/native/tags.yaml) --gen_lazy_ts_backend",
tools = ["//tools/setup_helpers:generate_code"],
)

filegroup(
name = "cpp_generated_code",
data = [":all_generated_code"],
data = [":generate-code"],
srcs = libtorch_cpp_generated_sources,
)

filegroup(
name = "python_generated_code",
data = [":all_generated_code"],
data = [":generate-code"],
srcs = libtorch_python_generated_sources,
)

Expand Down
9 changes: 3 additions & 6 deletions build.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ def define_targets(rules):
"--native-functions-path $(location :native_functions.yaml) " +
"--tags-path=$(location :tags.yaml) " +
"--gen_lazy_ts_backend",
tags = [
# Filter this target out for Bazel until we are ready to
# use it. When we refactor this for fbcode it will start
# to conflict with the Bazel code generator.
"-bazel",
],
)

rules.genrule(
Expand Down Expand Up @@ -117,4 +111,7 @@ _GENERATED_CPP = [
"torch/csrc/autograd/generated/python_torch_functions_1.cpp",
"torch/csrc/autograd/generated/python_torch_functions_2.cpp",
"torch/csrc/autograd/generated/python_variable_methods.cpp",
"torch/csrc/lazy/generated/LazyNativeFunctions.cpp",
"torch/csrc/lazy/generated/RegisterAutogradLazy.cpp",
"torch/csrc/lazy/generated/RegisterLazy.cpp",
]

0 comments on commit ac45fb9

Please sign in to comment.