mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Move version.h to torch/headeronly (#164381)
Differential Revision: [D83685392](https://our.internmc.facebook.com/intern/diff/D83685392) Pull Request resolved: https://github.com/pytorch/pytorch/pull/164381 Approved by: https://github.com/janeyx99
This commit is contained in:
committed by
PyTorch MergeBot
parent
b13cd141b3
commit
f37a6523ef
2
.gitignore
vendored
2
.gitignore
vendored
@ -88,7 +88,7 @@ torch_compile_debug/
|
|||||||
# Listed manually because some files in this directory are not generated
|
# Listed manually because some files in this directory are not generated
|
||||||
torch/testing/_internal/generated/annotated_fn_args.py
|
torch/testing/_internal/generated/annotated_fn_args.py
|
||||||
torch/testing/_internal/data/*.pt
|
torch/testing/_internal/data/*.pt
|
||||||
torch/csrc/api/include/torch/version.h
|
torch/headeronly/version.h
|
||||||
torch/csrc/cudnn/cuDNN.cpp
|
torch/csrc/cudnn/cuDNN.cpp
|
||||||
torch/csrc/generated
|
torch/csrc/generated
|
||||||
torch/csrc/generic/TensorMethods.cpp
|
torch/csrc/generic/TensorMethods.cpp
|
||||||
|
@ -13,6 +13,9 @@ load(":build_variables.bzl", "jit_core_sources", "lazy_tensor_ts_sources", "libt
|
|||||||
load(":ufunc_defs.bzl", "aten_ufunc_generated_cpu_kernel_sources", "aten_ufunc_generated_cpu_sources", "aten_ufunc_generated_cuda_sources")
|
load(":ufunc_defs.bzl", "aten_ufunc_generated_cpu_kernel_sources", "aten_ufunc_generated_cpu_sources", "aten_ufunc_generated_cuda_sources")
|
||||||
load("//:tools/bazel.bzl", "rules")
|
load("//:tools/bazel.bzl", "rules")
|
||||||
|
|
||||||
|
# Export files for use by torch/headeronly (where version.h generation now lives)
|
||||||
|
exports_files(["version.txt"])
|
||||||
|
|
||||||
define_targets(rules = rules)
|
define_targets(rules = rules)
|
||||||
|
|
||||||
COMMON_COPTS = [
|
COMMON_COPTS = [
|
||||||
@ -690,7 +693,9 @@ cc_library(
|
|||||||
"torch/csrc/*/generated/*.h",
|
"torch/csrc/*/generated/*.h",
|
||||||
"torch/csrc/jit/serialization/mobile_bytecode_generated.h",
|
"torch/csrc/jit/serialization/mobile_bytecode_generated.h",
|
||||||
] + torch_cuda_headers,
|
] + torch_cuda_headers,
|
||||||
) + GENERATED_AUTOGRAD_CPP + [":version_h"],
|
) + GENERATED_AUTOGRAD_CPP + [
|
||||||
|
"//torch/headeronly:version_h",
|
||||||
|
],
|
||||||
includes = [
|
includes = [
|
||||||
"third_party/kineto/libkineto/include",
|
"third_party/kineto/libkineto/include",
|
||||||
"torch/csrc",
|
"torch/csrc",
|
||||||
|
@ -1038,7 +1038,8 @@ def define_buck_targets(
|
|||||||
name = "generated-version-header",
|
name = "generated-version-header",
|
||||||
header_namespace = "torch",
|
header_namespace = "torch",
|
||||||
exported_headers = {
|
exported_headers = {
|
||||||
"version.h": ":generate-version-header[version.h]",
|
"headeronly/version.h": ":generate-version-header[version.h]",
|
||||||
|
"version.h": "torch/csrc/api/include/torch/version.h"
|
||||||
},
|
},
|
||||||
labels = labels,
|
labels = labels,
|
||||||
)
|
)
|
||||||
@ -1047,19 +1048,27 @@ def define_buck_targets(
|
|||||||
fb_native.genrule(
|
fb_native.genrule(
|
||||||
name = "generate-version-header",
|
name = "generate-version-header",
|
||||||
srcs = [
|
srcs = [
|
||||||
"torch/csrc/api/include/torch/version.h.in",
|
"torch/headeronly/version.h.in",
|
||||||
"version.txt",
|
"version.txt",
|
||||||
],
|
],
|
||||||
cmd = "$(exe {}tools:gen-version-header) ".format(ROOT_PATH) + " ".join([
|
cmd = "mkdir -p $OUT/torch/headeronly && $(exe {}tools:gen-version-header) ".format(ROOT_PATH) + " ".join([
|
||||||
"--template-path",
|
"--template-path",
|
||||||
"torch/csrc/api/include/torch/version.h.in",
|
"torch/headeronly/version.h.in",
|
||||||
"--version-path",
|
"--version-path",
|
||||||
"version.txt",
|
"version.txt",
|
||||||
"--output-path",
|
"--output-path",
|
||||||
"$OUT/version.h",
|
"$OUT/torch/headeronly/version.h",
|
||||||
|
]),
|
||||||
|
cmd_exe = "md $OUT\\torch\\headeronly 2>nul & $(exe {}tools:gen-version-header) ".format(ROOT_PATH) + " ".join([
|
||||||
|
"--template-path",
|
||||||
|
"torch/headeronly/version.h.in",
|
||||||
|
"--version-path",
|
||||||
|
"version.txt",
|
||||||
|
"--output-path",
|
||||||
|
"$OUT\\torch\\headeronly\\version.h",
|
||||||
]),
|
]),
|
||||||
outs = {
|
outs = {
|
||||||
"version.h": ["version.h"],
|
"version.h": ["torch/headeronly/version.h"],
|
||||||
},
|
},
|
||||||
default_outs = ["."],
|
default_outs = ["."],
|
||||||
)
|
)
|
||||||
|
12
build.bzl
12
build.bzl
@ -142,18 +142,6 @@ def define_targets(rules):
|
|||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
rules.genrule(
|
|
||||||
name = "version_h",
|
|
||||||
srcs = [
|
|
||||||
":torch/csrc/api/include/torch/version.h.in",
|
|
||||||
":version.txt",
|
|
||||||
],
|
|
||||||
outs = ["torch/csrc/api/include/torch/version.h"],
|
|
||||||
cmd = "$(execpath //tools/setup_helpers:gen_version_header) " +
|
|
||||||
"--template-path $(location :torch/csrc/api/include/torch/version.h.in) " +
|
|
||||||
"--version-path $(location :version.txt) --output-path $@ ",
|
|
||||||
tools = ["//tools/setup_helpers:gen_version_header"],
|
|
||||||
)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# ATen generated code
|
# ATen generated code
|
||||||
|
@ -243,8 +243,8 @@ configure_file("${TORCH_SRC_DIR}/_utils_internal.py"
|
|||||||
COPYONLY)
|
COPYONLY)
|
||||||
|
|
||||||
# Generate header with version info
|
# Generate header with version info
|
||||||
configure_file("${TORCH_SRC_DIR}/csrc/api/include/torch/version.h.in"
|
configure_file("${TORCH_SRC_DIR}/headeronly/version.h.in"
|
||||||
"${TORCH_SRC_DIR}/csrc/api/include/torch/version.h"
|
"${TORCH_SRC_DIR}/headeronly/version.h"
|
||||||
@ONLY)
|
@ONLY)
|
||||||
|
|
||||||
set(GENERATED_CXX_TORCH
|
set(GENERATED_CXX_TORCH
|
||||||
|
@ -16,6 +16,7 @@ def _is_cpu_static_dispatch_build():
|
|||||||
# build structure aims to replicate Bazel as much as possible, most of
|
# build structure aims to replicate Bazel as much as possible, most of
|
||||||
# the rules simply forward to the Bazel definitions.
|
# the rules simply forward to the Bazel definitions.
|
||||||
rules = struct(
|
rules = struct(
|
||||||
|
alias = native.alias,
|
||||||
cc_binary = cc_binary,
|
cc_binary = cc_binary,
|
||||||
cc_library = cc_library,
|
cc_library = cc_library,
|
||||||
cc_test = cc_test,
|
cc_test = cc_test,
|
||||||
|
@ -11,5 +11,8 @@ py_binary(
|
|||||||
py_binary(
|
py_binary(
|
||||||
name = "gen_version_header",
|
name = "gen_version_header",
|
||||||
srcs = ["gen_version_header.py"],
|
srcs = ["gen_version_header.py"],
|
||||||
visibility = ["//:__pkg__"],
|
visibility = [
|
||||||
|
"//:__pkg__",
|
||||||
|
"//torch/headeronly:__pkg__",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
@ -13,5 +13,8 @@ def define_targets(rules):
|
|||||||
rules.py_binary(
|
rules.py_binary(
|
||||||
name = "gen_version_header",
|
name = "gen_version_header",
|
||||||
srcs = ["gen_version_header.py"],
|
srcs = ["gen_version_header.py"],
|
||||||
visibility = ["//:__pkg__"],
|
visibility = [
|
||||||
|
"//:__pkg__",
|
||||||
|
"//torch/headeronly:__pkg__",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
1
torch/csrc/api/include/torch/version.h
Normal file
1
torch/csrc/api/include/torch/version.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include <torch/headeronly/version.h>
|
@ -1,9 +1,35 @@
|
|||||||
def define_targets(rules):
|
def define_targets(rules):
|
||||||
|
# workaround issue where open source bazel requires $(location ...)
|
||||||
|
# for filepaths but the buck conversion requires no $(location ...)
|
||||||
|
# for filepaths.
|
||||||
|
is_buck = hasattr(native, "read_config")
|
||||||
|
template_arg = "version.h.in" if is_buck else "$(location version.h.in)"
|
||||||
|
|
||||||
|
genrule_args = {
|
||||||
|
"name": "version_h",
|
||||||
|
"srcs": [
|
||||||
|
"version.h.in",
|
||||||
|
"//:version.txt",
|
||||||
|
],
|
||||||
|
"outs": ["version.h"],
|
||||||
|
"cmd": "$(execpath //tools/setup_helpers:gen_version_header) " +
|
||||||
|
"--template-path " + template_arg + " " +
|
||||||
|
"--version-path $(location //:version.txt) --output-path $@ ",
|
||||||
|
"tools": ["//tools/setup_helpers:gen_version_header"],
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add visibility only for Bazel, buck genrule in fbcode.bzl does not
|
||||||
|
# support this argument
|
||||||
|
if not is_buck:
|
||||||
|
genrule_args["visibility"] = ["//visibility:public"]
|
||||||
|
|
||||||
|
rules.genrule(**genrule_args)
|
||||||
|
|
||||||
rules.cc_library(
|
rules.cc_library(
|
||||||
name = "torch_headeronly",
|
name = "torch_headeronly",
|
||||||
hdrs = rules.glob([
|
hdrs = rules.glob([
|
||||||
"**/*.h"
|
"**/*.h"
|
||||||
]),
|
]) + ["version.h.in"],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//torch/headeronly/macros",
|
"//torch/headeronly/macros",
|
||||||
|
@ -40,6 +40,7 @@ def define_torch_headeronly_ovrsource(name, is_mobile):
|
|||||||
],
|
],
|
||||||
exported_deps = [
|
exported_deps = [
|
||||||
":ovrsource_torch_headeronly_cmake_macros.h",
|
":ovrsource_torch_headeronly_cmake_macros.h",
|
||||||
|
":generate-version-header",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user