Skip to content

Commit

Permalink
use ufunc_defs.bzl in BUILD.bazel
Browse files Browse the repository at this point in the history
Pull Request resolved: pytorch#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
  • Loading branch information
Michael Andreas Dagitses authored and pytorchmergebot committed Jun 16, 2022
1 parent 24c2aff commit c6c207f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
3 changes: 2 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
30 changes: 0 additions & 30 deletions aten.bzl
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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
]]

0 comments on commit c6c207f

Please sign in to comment.