Skip to content

Commit

Permalink
eliminate Bazel's libtorch_cpp_generated_sources
Browse files Browse the repository at this point in the history
Pull Request resolved: pytorch#76179

This list is redundant with the shared build structure.

Differential Revision: [D35818500](https://our.internmc.facebook.com/intern/diff/D35818500/)

**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D35818500/)!

Approved by: https://github.com/dreiss
  • Loading branch information
Michael Andreas Dagitses authored and pytorchmergebot committed May 17, 2022
1 parent a013d83 commit e517fc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 40 deletions.
41 changes: 8 additions & 33 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ load("//:tools/build_variables.bzl", "jit_core_sources", "libtorch_core_sources"
load("//tools/rules:cu.bzl", "cu_library")
load("//tools/config:defs.bzl", "if_cuda")
load("//:aten.bzl", "intern_build_aten_ops", "generate_aten", "aten_ufunc_generated_cpu_sources", "aten_ufunc_generated_cpu_kernel_sources", "aten_ufunc_generated_cuda_sources")
load(":build.bzl", "define_targets", "GENERATED_AUTOGRAD_PYTHON")
load(":build.bzl", "define_targets", "GENERATED_AUTOGRAD_CPP", "GENERATED_AUTOGRAD_PYTHON")

define_targets(rules = rules)

Expand Down Expand Up @@ -102,37 +102,10 @@ generate_aten(
generator = "//torchgen:gen",
)

libtorch_cpp_generated_sources = [
"torch/csrc/autograd/generated/VariableType.h",
"torch/csrc/autograd/generated/VariableType_0.cpp",
"torch/csrc/autograd/generated/VariableType_1.cpp",
"torch/csrc/autograd/generated/VariableType_2.cpp",
"torch/csrc/autograd/generated/VariableType_3.cpp",
"torch/csrc/autograd/generated/VariableType_4.cpp",
# "torch/csrc/autograd/generated/VariableTypeEverything.cpp",
"torch/csrc/autograd/generated/TraceType_0.cpp",
"torch/csrc/autograd/generated/TraceType_1.cpp",
"torch/csrc/autograd/generated/TraceType_2.cpp",
"torch/csrc/autograd/generated/TraceType_3.cpp",
"torch/csrc/autograd/generated/TraceType_4.cpp",
# "torch/csrc/autograd/generated/TraceTypeEverything.cpp",
"torch/csrc/autograd/generated/ADInplaceOrViewType_0.cpp",
"torch/csrc/autograd/generated/ADInplaceOrViewType_1.cpp",
# "torch/csrc/autograd/generated/ADInplaceOrViewTypeEverything.cpp",
"torch/csrc/autograd/generated/Functions.h",
"torch/csrc/autograd/generated/Functions.cpp",
"torch/csrc/autograd/generated/variable_factories.h",
"torch/csrc/lazy/generated/LazyIr.h",
"torch/csrc/lazy/generated/LazyNativeFunctions.h",
"torch/csrc/lazy/generated/LazyNativeFunctions.cpp",
"torch/csrc/lazy/generated/RegisterAutogradLazy.cpp",
"torch/csrc/lazy/generated/RegisterLazy.cpp",
]

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

exports_files(
Expand Down Expand Up @@ -1622,7 +1595,7 @@ cc_library(
"torch/csrc/autograd/generated/variable_factories.h",
"torch/csrc/autograd/generated/Functions.h",
] + torch_cuda_headers,
) + [":cpp_generated_code", ":version_h"],
) + GENERATED_AUTOGRAD_CPP + [":version_h"],
includes = [
"torch/csrc",
"torch/csrc/api/include",
Expand Down Expand Up @@ -1667,8 +1640,7 @@ cc_library(
"torch/csrc/cuda/nccl.cpp",
"torch/csrc/distributed/c10d/quantization/quantization_gpu.cu",
],
)) + libtorch_core_sources + libtorch_distributed_sources + torch_cpp_srcs + libtorch_extra_sources + jit_core_sources + lazy_tensor_ts_sources +[
":cpp_generated_code",
)) + libtorch_core_sources + libtorch_distributed_sources + torch_cpp_srcs + libtorch_extra_sources + jit_core_sources + lazy_tensor_ts_sources + GENERATED_AUTOGRAD_CPP + [
"torch/csrc/jit/serialization/flatbuffer_serializer.cpp",
"torch/csrc/jit/mobile/flatbuffer_loader.cpp"
],
Expand Down Expand Up @@ -1701,7 +1673,10 @@ cc_library(
"**/*.h",
"**/*.cuh",
]) + [
":cpp_generated_code",
# We need the filegroup here because the raw list causes Bazel
# to see duplicate files. It knows how to deduplicate with the
# filegroup.
":cpp_generated_code"
],
includes = [
"torch/csrc/api/include",
Expand Down
16 changes: 9 additions & 7 deletions build.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def define_targets(rules):
":ts_native_functions.yaml",
],
tools = ["//tools/setup_helpers:generate_code"],
outs = _GENERATED_CPP + GENERATED_AUTOGRAD_H + GENERATED_LAZY_H + GENERATED_TESTING_PY,
outs = GENERATED_AUTOGRAD_CPP + GENERATED_AUTOGRAD_PYTHON + GENERATED_TESTING_PY,
cmd = "$(location //tools/setup_helpers:generate_code) " +
"--gen-dir=$(RULEDIR) " +
"--native-functions-path $(location :native_functions.yaml) " +
Expand Down Expand Up @@ -66,15 +66,17 @@ def define_targets(rules):
# generate-code that use these lists are moved into the shared
# structure as well.

_GENERATED_AUTOGRAD_PYTHON_H = [
_GENERATED_AUTOGRAD_PYTHON_HEADERS = [
"torch/csrc/autograd/generated/python_functions.h",
]

GENERATED_AUTOGRAD_H = [
_GENERATED_AUTOGRAD_CPP_HEADERS = [
"torch/csrc/autograd/generated/Functions.h",
"torch/csrc/autograd/generated/VariableType.h",
"torch/csrc/autograd/generated/variable_factories.h",
] + _GENERATED_AUTOGRAD_PYTHON_H
]

GENERATED_AUTOGRAD_H = _GENERATED_AUTOGRAD_CPP_HEADERS + _GENERATED_AUTOGRAD_PYTHON_HEADERS

GENERATED_TESTING_PY = [
"torch/testing/_internal/generated/annotated_fn_args.py",
Expand Down Expand Up @@ -103,9 +105,9 @@ _GENERATED_AUTOGRAD_PYTHON_CPP = [
"torch/csrc/autograd/generated/python_variable_methods.cpp",
]

GENERATED_AUTOGRAD_PYTHON = _GENERATED_AUTOGRAD_PYTHON_H + _GENERATED_AUTOGRAD_PYTHON_CPP
GENERATED_AUTOGRAD_PYTHON = _GENERATED_AUTOGRAD_PYTHON_HEADERS + _GENERATED_AUTOGRAD_PYTHON_CPP

_GENERATED_CPP = [
GENERATED_AUTOGRAD_CPP = [
"torch/csrc/autograd/generated/Functions.cpp",
"torch/csrc/autograd/generated/VariableType_0.cpp",
"torch/csrc/autograd/generated/VariableType_1.cpp",
Expand All @@ -122,4 +124,4 @@ _GENERATED_CPP = [
"torch/csrc/lazy/generated/LazyNativeFunctions.cpp",
"torch/csrc/lazy/generated/RegisterAutogradLazy.cpp",
"torch/csrc/lazy/generated/RegisterLazy.cpp",
] + _GENERATED_AUTOGRAD_PYTHON_CPP
] + _GENERATED_AUTOGRAD_CPP_HEADERS + GENERATED_LAZY_H

0 comments on commit e517fc8

Please sign in to comment.