use ufunc_defs.bzl in BUILD.bazel

Pull Request resolved: https://github.com/pytorch/pytorch/pull/77747

This allows us to remove some duplication in aten.bzl.

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

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

Approved by: https://github.com/seemethere
This commit is contained in:
Michael Andreas Dagitses
2022-06-15 18:55:20 -07:00
committed by PyTorch MergeBot
parent 24c2aff1b2
commit c6c207f620
2 changed files with 2 additions and 31 deletions

View File

@ -6,9 +6,10 @@ load("//third_party:substitution.bzl", "header_template_rule")
load("//:tools/bazel.bzl", "rules")
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("//:aten.bzl", "intern_build_aten_ops", "generate_aten")
load(":build.bzl", "define_targets", "GENERATED_AUTOGRAD_CPP", "GENERATED_AUTOGRAD_PYTHON")
load(":build_variables.bzl", "jit_core_sources", "libtorch_core_sources", "libtorch_cuda_sources", "libtorch_distributed_sources", "libtorch_extra_sources", "libtorch_nvfuser_generated_headers", "libtorch_nvfuser_runtime_sources", "libtorch_python_core_sources", "torch_cpp_srcs", "lazy_tensor_ts_sources")
load(":ufunc_defs.bzl", "aten_ufunc_generated_cpu_sources", "aten_ufunc_generated_cpu_kernel_sources", "aten_ufunc_generated_cuda_sources")
define_targets(rules = rules)

View File

@ -1,6 +1,5 @@
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_cc//cc:defs.bzl", "cc_library")
load(":build_variables.bzl", "aten_ufunc_headers")
CPU_CAPABILITY_NAMES = ["DEFAULT", "AVX2"]
CAPABILITY_COMPILER_FLAGS = {
@ -95,32 +94,3 @@ generate_aten = rule(
"srcs": attr.label_list(allow_files = True),
},
)
# copy pasted from ufunc_defs.bzl, as ufuncs_defs.bzl cannot be included
# from BUILD.bazel because it has a directory relative load, and Bazel
# always load from workspace root. The "correct" fix would be to move
# build_variables.bzl to the top level but I don't have time to do this at
# the moment.
aten_ufunc_names = [
paths.split_extension(paths.basename(h))[0]
for h in aten_ufunc_headers
]
def aten_ufunc_generated_cpu_sources(gencode_pattern = "{}"):
return [gencode_pattern.format(name) for name in [
"UfuncCPU_{}.cpp".format(n)
for n in aten_ufunc_names
]]
def aten_ufunc_generated_cpu_kernel_sources(gencode_pattern = "{}"):
return [gencode_pattern.format(name) for name in [
"UfuncCPUKernel_{}.cpp".format(n)
for n in aten_ufunc_names
]]
def aten_ufunc_generated_cuda_sources(gencode_pattern = "{}"):
return [gencode_pattern.format(name) for name in [
"UfuncCUDA_{}.cu".format(n)
for n in aten_ufunc_names
]]