From 501d0729cb7cfd25aebb2c0e82cef035bf4e7e78 Mon Sep 17 00:00:00 2001 From: Michael Andreas Dagitses Date: Thu, 2 Jun 2022 08:57:03 -0700 Subject: [PATCH] move build_variables.bzl and ufunc_defs.bzl from pytorch-root/tools/ to the root Pull Request resolved: https://github.com/pytorch/pytorch/pull/78542 This makes importing easier in different build systems that have different absolute names for the pytorch-root. Differential Revision: [D36782582](https://our.internmc.facebook.com/intern/diff/D36782582/) **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D36782582/)! Approved by: https://github.com/malfet --- BUILD.bazel | 2 +- BUILD.buck | 4 ++-- MANIFEST.in | 2 ++ aten.bzl | 2 +- tools/build_variables.bzl => build_variables.bzl | 0 cmake/Codegen.cmake | 4 ++-- pt_defs.oss.bzl | 11 ++++------- tools/ufunc_defs.bzl => ufunc_defs.bzl | 0 8 files changed, 12 insertions(+), 13 deletions(-) rename tools/build_variables.bzl => build_variables.bzl (100%) rename tools/ufunc_defs.bzl => ufunc_defs.bzl (100%) diff --git a/BUILD.bazel b/BUILD.bazel index db4d914377d9..5468632ff119 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -4,11 +4,11 @@ load("@rules_proto//proto:defs.bzl", "proto_library") load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "cc_test") load("//third_party:substitution.bzl", "header_template_rule") load("//:tools/bazel.bzl", "rules") -load("//:tools/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("//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_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") define_targets(rules = rules) diff --git a/BUILD.buck b/BUILD.buck index 09f8ca20c798..744efaac3662 100644 --- a/BUILD.buck +++ b/BUILD.buck @@ -1,7 +1,7 @@ load("//tools/build_defs:glob_defs.bzl", "subdir_glob") load("//tools/build_defs:fb_xplat_genrule.bzl", "fb_xplat_genrule") load( - "//tools:build_variables.bzl", + ":build_variables.bzl", "aten_cpu_source_list", "aten_native_source_list", "core_sources_common", @@ -10,7 +10,7 @@ load( "libtorch_profiler_sources", ) load( - "//:pt_defs.oss.bzl", + ":pt_defs.oss.bzl", "USED_PT_BACKENDS", "build_aten_cpu", "gen_aten_files", diff --git a/MANIFEST.in b/MANIFEST.in index d238d96803de..acf4c7291f43 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,8 +4,10 @@ include CITATION include LICENSE include NOTICE include .gitmodules +include build_variables.bzl include mypy.ini include requirements.txt +include ufunc_defs.bzl include version.txt recursive-include android *.* recursive-include aten *.* diff --git a/aten.bzl b/aten.bzl index c97f22284f10..339679006300 100644 --- a/aten.bzl +++ b/aten.bzl @@ -1,6 +1,6 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@rules_cc//cc:defs.bzl", "cc_library") -load("//:tools/build_variables.bzl", "aten_ufunc_headers") +load(":build_variables.bzl", "aten_ufunc_headers") CPU_CAPABILITY_NAMES = ["DEFAULT", "AVX2"] CAPABILITY_COMPILER_FLAGS = { diff --git a/tools/build_variables.bzl b/build_variables.bzl similarity index 100% rename from tools/build_variables.bzl rename to build_variables.bzl diff --git a/cmake/Codegen.cmake b/cmake/Codegen.cmake index 8fa42e89411f..a73811000b08 100644 --- a/cmake/Codegen.cmake +++ b/cmake/Codegen.cmake @@ -349,11 +349,11 @@ function(append_filelist name outputvar) set(_rootdir "${${CMAKE_PROJECT_NAME}_SOURCE_DIR}/") # configure_file adds its input to the list of CMAKE_RERUN dependencies configure_file( - ${PROJECT_SOURCE_DIR}/tools/build_variables.bzl + ${PROJECT_SOURCE_DIR}/build_variables.bzl ${PROJECT_BINARY_DIR}/caffe2/build_variables.bzl) execute_process( COMMAND "${PYTHON_EXECUTABLE}" -c - "exec(open('${PROJECT_SOURCE_DIR}/tools/build_variables.bzl').read());print(';'.join(['${_rootdir}' + x for x in ${name}]))" + "exec(open('${PROJECT_SOURCE_DIR}/build_variables.bzl').read());print(';'.join(['${_rootdir}' + x for x in ${name}]))" WORKING_DIRECTORY "${_rootdir}" RESULT_VARIABLE _retval OUTPUT_VARIABLE _tempvar) diff --git a/pt_defs.oss.bzl b/pt_defs.oss.bzl index dedf281e25c3..c8f2dcfea613 100644 --- a/pt_defs.oss.bzl +++ b/pt_defs.oss.bzl @@ -1,16 +1,13 @@ load("@bazel_skylib//lib:paths.bzl", "paths") +load("//tools/build_defs:fb_xplat_genrule.bzl", "fb_xplat_genrule") +load("//tools/build_defs:type_defs.bzl", "is_list", "is_string") +load(":build_variables.bzl", "aten_native_source_list") load( - "//tools:build_variables.bzl", - "aten_native_source_list", -) -load( - "//tools:ufunc_defs.bzl", + ":ufunc_defs.bzl", "aten_ufunc_generated_cpu_kernel_sources", "aten_ufunc_generated_cpu_sources", "aten_ufunc_generated_cuda_sources", ) -load("//tools/build_defs:fb_xplat_genrule.bzl", "fb_xplat_genrule") -load("//tools/build_defs:type_defs.bzl", "is_list", "is_string") USED_PT_BACKENDS = [ "CPU", diff --git a/tools/ufunc_defs.bzl b/ufunc_defs.bzl similarity index 100% rename from tools/ufunc_defs.bzl rename to ufunc_defs.bzl