extract out a caffe2 macros library (#98156)

Slowly carving out the minimal caffe2 dependencies to build PyTorch.

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

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D44609764/)!
Pull Request resolved: https://github.com/pytorch/pytorch/pull/98156
Approved by: https://github.com/ezyang, https://github.com/PaliC
This commit is contained in:
mikey dagitses
2023-04-03 17:42:58 -07:00
committed by PyTorch MergeBot
parent f6272ce79d
commit 950431c334
2 changed files with 48 additions and 36 deletions

View File

@ -1261,7 +1261,7 @@ cc_library(
copts = CAFFE2_COPTS,
visibility = ["//visibility:public"],
deps = [
":caffe2_core_macros_h",
":caffe2_core_macros",
"//c10:headers",
"//caffe2/proto:caffe2_pb",
],
@ -1292,41 +1292,46 @@ genrule(
cc_library(
name = "caffe2_headers",
hdrs = glob([
"caffe2/contrib/aten/*.h",
"caffe2/contrib/gloo/*.h",
"caffe2/core/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Converters/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Generated/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Graph/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Representations/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Support/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Transformations/*.h",
"caffe2/core/nomnigraph/tests/*.h",
"caffe2/db/*.h",
"caffe2/distributed/*.h",
"caffe2/ideep/*.h",
"caffe2/ideep/operators/*.h",
"caffe2/ideep/operators/quantization/*.h",
"caffe2/ideep/utils/*.h",
"caffe2/onnx/*.h",
"caffe2/operators/*.h",
"caffe2/operators/rnn/*.h",
"caffe2/opt/*.h",
"caffe2/perfkernels/*.h",
"caffe2/predictor/*.h",
"caffe2/predictor/emulator/*.h",
"caffe2/quantization/server/*.h",
"caffe2/queue/*.h",
"caffe2/serialize/*.h",
"caffe2/sgd/*.h",
"caffe2/share/contrib/depthwise/*.h",
"caffe2/transforms/*.h",
"caffe2/utils/*.h",
"caffe2/utils/math/*.h",
"caffe2/utils/threadpool/*.h",
"modules/**/*.h",
]) + if_cuda(glob([
hdrs = glob(
[
"caffe2/contrib/aten/*.h",
"caffe2/contrib/gloo/*.h",
"caffe2/core/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Converters/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Generated/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Graph/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Representations/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Support/*.h",
"caffe2/core/nomnigraph/include/nomnigraph/Transformations/*.h",
"caffe2/core/nomnigraph/tests/*.h",
"caffe2/db/*.h",
"caffe2/distributed/*.h",
"caffe2/ideep/*.h",
"caffe2/ideep/operators/*.h",
"caffe2/ideep/operators/quantization/*.h",
"caffe2/ideep/utils/*.h",
"caffe2/onnx/*.h",
"caffe2/operators/*.h",
"caffe2/operators/rnn/*.h",
"caffe2/opt/*.h",
"caffe2/perfkernels/*.h",
"caffe2/predictor/*.h",
"caffe2/predictor/emulator/*.h",
"caffe2/quantization/server/*.h",
"caffe2/queue/*.h",
"caffe2/serialize/*.h",
"caffe2/sgd/*.h",
"caffe2/share/contrib/depthwise/*.h",
"caffe2/transforms/*.h",
"caffe2/utils/*.h",
"caffe2/utils/math/*.h",
"caffe2/utils/threadpool/*.h",
"modules/**/*.h",
],
exclude = [
"caffe2/core/macros.h",
],
) + if_cuda(glob([
"caffe2/**/*.cuh",
"caffe2/image/*.h",
])) + [":generated_caffe2_aten_op_headers"],
@ -1337,6 +1342,7 @@ cc_library(
],
visibility = ["//visibility:public"],
deps = [
":caffe2_core_macros",
":caffe2_for_aten_headers",
"//caffe2/proto:caffe2_pb",
"//caffe2/proto:cc_proto",
@ -1395,6 +1401,7 @@ cc_library(
linkstatic = 1,
visibility = ["//visibility:public"],
deps = [
":caffe2_core_macros",
":caffe2_dnnlowp_avx2_ops",
":caffe2_headers",
":caffe2_perfkernels_avx",

View File

@ -6,6 +6,11 @@ load(
)
def define_targets(rules):
rules.cc_library(
name = "caffe2_core_macros",
hdrs = [":caffe2_core_macros_h"],
)
rules.cmake_configure_file(
name = "caffe2_core_macros_h",
src = "caffe2/core/macros.h.in",