From ac45fb9b937d43947021cf58499a0b067ffba0e1 Mon Sep 17 00:00:00 2001 From: mikey dagitses Date: Wed, 4 May 2022 06:48:20 -0700 Subject: [PATCH] switch Bazel to the shared generate-code genrule (#75790) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/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 2822d4c5b48c6d9282149b2d43cf72d645237196) --- BUILD.bazel | 22 ++-------------------- build.bzl | 9 +++------ 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 0835421d38d..79bf1b4018b 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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, ) diff --git a/build.bzl b/build.bzl index 247e4097d16..6302d55b844 100644 --- a/build.bzl +++ b/build.bzl @@ -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( @@ -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", ]