pytorch/c10/core/build.bzl
Scott Wolchok ade8fee512 Use c10 version of half/bfloat16 in executorch (#144111)
Summary:
X-link: https://github.com/pytorch/executorch/pull/7040

Accomplished by importing relevant files from c10 into
executorch/runtime/core/portable_type/c10, and then using `using` in
the top-level ExecuTorch headers. This approach should keep the
ExecuTorch build hermetic for embedded use cases. In the future, we
should add a CI job to ensure the c10 files stay identical to the
PyTorch ones.
ghstack-source-id: 260047850
exported-using-ghexport

Test Plan: builds

Differential Revision: D66106969

Pull Request resolved: https://github.com/pytorch/pytorch/pull/144111
Approved by: https://github.com/malfet
2025-02-08 22:40:14 +00:00

121 lines
3.1 KiB
Python

def define_targets(rules):
rules.cc_library(
name = "CPUAllocator",
srcs = ["CPUAllocator.cpp"],
hdrs = ["CPUAllocator.h"],
linkstatic = True,
local_defines = ["C10_BUILD_MAIN_LIB"],
visibility = ["//visibility:public"],
deps = [
":alignment",
":base",
"//c10/mobile:CPUCachingAllocator",
"//c10/mobile:CPUProfilingAllocator",
"//c10/util:base",
],
# This library defines a flag, The use of alwayslink keeps it
# from being stripped.
alwayslink = True,
)
rules.cc_library(
name = "ScalarType",
hdrs = ["ScalarType.h"],
linkstatic = True,
local_defines = ["C10_BUILD_MAIN_LIB"],
visibility = ["//visibility:public"],
deps = ["//c10/util:base"],
)
rules.cc_library(
name = "alignment",
hdrs = ["alignment.h"],
linkstatic = True,
local_defines = ["C10_BUILD_MAIN_LIB"],
visibility = ["//visibility:public"],
)
rules.cc_library(
name = "alloc_cpu",
srcs = ["impl/alloc_cpu.cpp"],
hdrs = ["impl/alloc_cpu.h"],
linkstatic = True,
local_defines = ["C10_BUILD_MAIN_LIB"],
visibility = ["//visibility:public"],
deps = [
":alignment",
"//c10/macros",
"//c10/util:base",
],
# This library defines flags, The use of alwayslink keeps them
# from being stripped.
alwayslink = True,
)
rules.cc_library(
name = "base",
srcs = rules.glob(
[
"*.cpp",
"impl/*.cpp",
],
exclude = [
"CPUAllocator.cpp",
"impl/alloc_cpu.cpp",
],
),
hdrs = rules.glob(
[
"*.h",
"impl/*.h",
],
exclude = [
"CPUAllocator.h",
"impl/alloc_cpu.h",
],
),
linkstatic = True,
local_defines = ["C10_BUILD_MAIN_LIB"],
visibility = ["//visibility:public"],
deps = [
":ScalarType",
"//third_party/cpuinfo",
"//c10/macros",
"//c10/util:TypeCast",
"//c10/util:base",
"//c10/util:typeid",
],
# This library uses flags and registration. Do not let the
# linker remove them.
alwayslink = True,
)
rules.cc_library(
name = "base_headers",
srcs = [],
hdrs = rules.glob(
[
"*.h",
"impl/*.h",
],
exclude = [
"CPUAllocator.h",
"impl/alloc_cpu.h",
],
),
visibility = ["//visibility:public"],
)
rules.filegroup(
name = "headers",
srcs = rules.glob(
[
"*.h",
"impl/*.h",
],
exclude = [
"alignment.h",
],
),
visibility = ["//visibility:public"],
)