Import XNNPACK library and its dependencies

This is a preparatory step for releasing XNNPACK integration into TensorFlow Lite.

PiperOrigin-RevId: 285260004
Change-Id: I758f996a5351e65967f1c6af613719d644a49f49
This commit is contained in:
A. Unique TensorFlower 2019-12-12 13:36:24 -08:00 committed by TensorFlower Gardener
parent 606a542c81
commit b18db52708
16 changed files with 419 additions and 0 deletions

View File

@ -22,7 +22,10 @@ load(
"def_file_filter_configure",
)
load("//third_party/FP16:workspace.bzl", FP16 = "repo")
load("//third_party/FXdiv:workspace.bzl", FXdiv = "repo")
load("//third_party/aws:workspace.bzl", aws = "repo")
load("//third_party/clog:workspace.bzl", clog = "repo")
load("//third_party/cpuinfo:workspace.bzl", cpuinfo = "repo")
load("//third_party/flatbuffers:workspace.bzl", flatbuffers = "repo")
load("//third_party/highwayhash:workspace.bzl", highwayhash = "repo")
load("//third_party/hwloc:workspace.bzl", hwloc = "repo")
@ -33,11 +36,16 @@ load("//third_party/opencl_headers:workspace.bzl", opencl_headers = "repo")
load("//third_party/kissfft:workspace.bzl", kissfft = "repo")
load("//third_party/keras_applications_archive:workspace.bzl", keras_applications = "repo")
load("//third_party/pasta:workspace.bzl", pasta = "repo")
load("//third_party/psimd:workspace.bzl", psimd = "repo")
load("//third_party/pthreadpool:workspace.bzl", pthreadpool = "repo")
def initialize_third_party():
""" Load third party repositories. See above load() statements. """
FP16()
FXdiv()
aws()
clog()
cpuinfo()
flatbuffers()
highwayhash()
hwloc()
@ -48,6 +56,8 @@ def initialize_third_party():
nasm()
opencl_headers()
pasta()
psimd()
pthreadpool()
# Sanitize a dependency so that it works correctly from code that includes
# TensorFlow as a submodule.
@ -127,6 +137,16 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""):
print("path_prefix was specified to tf_workspace but is no longer used " +
"and will be removed in the future.")
tf_http_archive(
name = "XNNPACK",
sha256 = "24b6285c679dece8805d2a7d63cc567413b7670279bc0c66a99e555123fe4700",
strip_prefix = "XNNPACK-9a88efe2d84fef93eb2b8acb6f0ac8f3cacee8b5",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/XNNPACK/archive/9a88efe2d84fef93eb2b8acb6f0ac8f3cacee8b5.zip",
"https://github.com/google/XNNPACK/archive/9a88efe2d84fef93eb2b8acb6f0ac8f3cacee8b5.zip",
],
)
# Important: If you are upgrading MKL-DNN, then update the version numbers
# in third_party/mkl_dnn/mkldnn.BUILD. In addition, the new version of
# MKL-DNN might require upgrading MKL ML libraries also. If they need to be

1
third_party/FXdiv/BUILD vendored Normal file
View File

@ -0,0 +1 @@
# This empty BUILD file is required to make Bazel treat this directory as a package.

15
third_party/FXdiv/BUILD.bazel vendored Normal file
View File

@ -0,0 +1,15 @@
# Description:
# C99/C++ library for division via fixed-point multiplication by inverse
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
exports_files(["LICENSE"])
cc_library(
name = "FXdiv",
hdrs = glob(["include/fxdiv.h"]),
includes = ["include"],
strip_include_prefix = "include",
)

15
third_party/FXdiv/workspace.bzl vendored Normal file
View File

@ -0,0 +1,15 @@
"""Loads the FXdiv library, used by XNNPACK & pthreadpool."""
load("//third_party:repo.bzl", "third_party_http_archive")
def repo():
third_party_http_archive(
name = "FXdiv",
strip_prefix = "FXdiv-f8c5354679ec2597792bc70a9e06eff50c508b9a",
sha256 = "7d3215bea832fe77091ec5666200b91156df6724da1e348205078346325fc45e",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/Maratyszcza/FXdiv/archive/f8c5354679ec2597792bc70a9e06eff50c508b9a.tar.gz",
"https://github.com/Maratyszcza/FXdiv/archive/f8c5354679ec2597792bc70a9e06eff50c508b9a.tar.gz",
],
build_file = "//third_party/FXdiv:BUILD.bazel",
)

1
third_party/clog/BUILD vendored Normal file
View File

@ -0,0 +1 @@
# This empty BUILD file is required to make Bazel treat this directory as a package.

35
third_party/clog/BUILD.bazel vendored Normal file
View File

@ -0,0 +1,35 @@
# Description:
# C-style (a-la printf) logging library
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
exports_files(["LICENSE"])
cc_library(
name = "clog",
srcs = [
"deps/clog/src/clog.c",
],
hdrs = [
"deps/clog/include/clog.h",
],
copts = [
"-Wno-unused-result",
],
linkopts = select({
":android": [
"-llog",
],
"//conditions:default": [
],
}),
strip_include_prefix = "deps/clog/include",
)
config_setting(
name = "android",
values = {"crosstool_top": "//external:android/crosstool"},
visibility = ["//visibility:public"],
)

15
third_party/clog/workspace.bzl vendored Normal file
View File

@ -0,0 +1,15 @@
"""Loads the clog library, used by cpuinfo and XNNPACK."""
load("//third_party:repo.bzl", "third_party_http_archive")
def repo():
third_party_http_archive(
name = "clog",
strip_prefix = "cpuinfo-d5e37adf1406cf899d7d9ec1d317c47506ccb970",
sha256 = "3f2dc1970f397a0e59db72f9fca6ff144b216895c1d606f6c94a507c1e53a025",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/pytorch/cpuinfo/archive/d5e37adf1406cf899d7d9ec1d317c47506ccb970.tar.gz",
"https://github.com/pytorch/cpuinfo/archive/d5e37adf1406cf899d7d9ec1d317c47506ccb970.tar.gz",
],
build_file = "//third_party/clog:BUILD.bazel",
)

1
third_party/cpuinfo/BUILD vendored Normal file
View File

@ -0,0 +1 @@
# This empty BUILD file is required to make Bazel treat this directory as a package.

222
third_party/cpuinfo/BUILD.bazel vendored Normal file
View File

@ -0,0 +1,222 @@
# cpuinfo, a library to detect information about the host CPU
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
exports_files(["LICENSE"])
C99OPTS = [
"-std=gnu99", # gnu99, not c99, because dprintf is used
"-Wno-vla",
"-D_GNU_SOURCE=1", # to use CPU_SETSIZE
"-DCPUINFO_INTERNAL=",
"-DCPUINFO_PRIVATE=",
]
# Source code common to all platforms.
COMMON_SRCS = [
"src/api.c",
"src/init.c",
]
# Architecture-specific sources and headers.
X86_SRCS = [
"src/x86/cache/descriptor.c",
"src/x86/cache/deterministic.c",
"src/x86/cache/init.c",
"src/x86/info.c",
"src/x86/init.c",
"src/x86/isa.c",
"src/x86/name.c",
"src/x86/topology.c",
"src/x86/uarch.c",
"src/x86/vendor.c",
]
ARM_SRCS = [
"src/arm/cache.c",
"src/arm/uarch.c",
]
# Platform-specific sources and headers
LINUX_SRCS = [
"src/linux/cpulist.c",
"src/linux/current.c",
"src/linux/multiline.c",
"src/linux/processors.c",
"src/linux/smallfile.c",
]
MOCK_LINUX_SRCS = [
"src/linux/mockfile.c",
]
MACH_SRCS = [
"src/mach/topology.c",
]
EMSCRIPTEN_SRCS = [
"src/emscripten/init.c",
]
PNACL_SRCS = [
"src/pnacl/init.c",
]
LINUX_X86_SRCS = [
"src/x86/linux/cpuinfo.c",
"src/x86/linux/init.c",
]
LINUX_ARM_SRCS = [
"src/arm/linux/chipset.c",
"src/arm/linux/clusters.c",
"src/arm/linux/cpuinfo.c",
"src/arm/linux/hwcap.c",
"src/arm/linux/init.c",
"src/arm/linux/midr.c",
]
LINUX_ARM32_SRCS = LINUX_ARM_SRCS + ["src/arm/linux/aarch32-isa.c"]
LINUX_ARM64_SRCS = LINUX_ARM_SRCS + ["src/arm/linux/aarch64-isa.c"]
ANDROID_ARM_SRCS = [
"src/arm/android/properties.c",
]
WINDOWS_X86_SRCS = [
"src/x86/windows/init.c",
]
MACH_X86_SRCS = [
"src/x86/mach/init.c",
]
MACH_ARM_SRCS = [
"src/arm/mach/init.c",
]
cc_library(
name = "cpuinfo_impl",
srcs = select({
":linux_x86_64": COMMON_SRCS + X86_SRCS + LINUX_SRCS + LINUX_X86_SRCS,
":macos_x86_64": COMMON_SRCS + X86_SRCS + MACH_SRCS + MACH_X86_SRCS,
":android_armv7": COMMON_SRCS + ARM_SRCS + LINUX_SRCS + LINUX_ARM32_SRCS + ANDROID_ARM_SRCS,
":android_arm64": COMMON_SRCS + ARM_SRCS + LINUX_SRCS + LINUX_ARM64_SRCS + ANDROID_ARM_SRCS,
":android_x86": COMMON_SRCS + X86_SRCS + LINUX_SRCS + LINUX_X86_SRCS,
":android_x86_64": COMMON_SRCS + X86_SRCS + LINUX_SRCS + LINUX_X86_SRCS,
":emscripten_wasm": COMMON_SRCS + EMSCRIPTEN_SRCS,
}),
copts = C99OPTS + [
"-Iexternal/cpuinfo/include",
"-Iexternal/cpuinfo/src",
],
linkstatic = True,
# Headers must be in textual_hdrs to allow us to set the standard to C99
textual_hdrs = [
"include/cpuinfo.h",
"src/linux/api.h",
"src/mach/api.h",
"src/cpuinfo/common.h",
"src/cpuinfo/internal-api.h",
"src/cpuinfo/log.h",
"src/cpuinfo/utils.h",
"src/x86/api.h",
"src/x86/cpuid.h",
"src/x86/linux/api.h",
"src/arm/android/api.h",
"src/arm/linux/api.h",
"src/arm/linux/cp.h",
"src/arm/api.h",
"src/arm/midr.h",
],
deps = [
"@clog",
],
)
cc_library(
name = "cpuinfo",
hdrs = [
"include/cpuinfo.h",
],
strip_include_prefix = "include",
deps = [
":cpuinfo_impl",
],
)
############################# Build configurations #############################
config_setting(
name = "linux_x86_64",
values = {"cpu": "k8"},
visibility = ["//visibility:public"],
)
config_setting(
name = "macos_x86_64",
values = {
"apple_platform_type": "macos",
"cpu": "darwin",
},
)
config_setting(
name = "android_armv7",
values = {
"crosstool_top": "//external:android/crosstool",
"cpu": "armeabi-v7a",
},
visibility = ["//visibility:public"],
)
config_setting(
name = "android_arm64",
values = {
"crosstool_top": "//external:android/crosstool",
"cpu": "arm64-v8a",
},
visibility = ["//visibility:public"],
)
config_setting(
name = "android_x86",
values = {
"crosstool_top": "//external:android/crosstool",
"cpu": "x86",
},
visibility = ["//visibility:public"],
)
config_setting(
name = "android_x86_64",
values = {
"crosstool_top": "//external:android/crosstool",
"cpu": "x86_64",
},
visibility = ["//visibility:public"],
)
config_setting(
name = "emscripten_wasm",
values = {
"cpu": "wasm",
},
)
config_setting(
name = "emscripten_wasmsimd",
values = {
"cpu": "wasm",
"features": "wasm_simd",
},
)
config_setting(
name = "emscripten_asmjs",
values = {
"cpu": "asmjs",
},
)

15
third_party/cpuinfo/workspace.bzl vendored Normal file
View File

@ -0,0 +1,15 @@
"""Loads the cpuinfo library, used by XNNPACK."""
load("//third_party:repo.bzl", "third_party_http_archive")
def repo():
third_party_http_archive(
name = "cpuinfo",
strip_prefix = "cpuinfo-d5e37adf1406cf899d7d9ec1d317c47506ccb970",
sha256 = "3f2dc1970f397a0e59db72f9fca6ff144b216895c1d606f6c94a507c1e53a025",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/pytorch/cpuinfo/archive/d5e37adf1406cf899d7d9ec1d317c47506ccb970.tar.gz",
"https://github.com/pytorch/cpuinfo/archive/d5e37adf1406cf899d7d9ec1d317c47506ccb970.tar.gz",
],
build_file = "//third_party/cpuinfo:BUILD.bazel",
)

1
third_party/psimd/BUILD vendored Normal file
View File

@ -0,0 +1 @@
# This empty BUILD file is required to make Bazel treat this directory as a package.

15
third_party/psimd/BUILD.bazel vendored Normal file
View File

@ -0,0 +1,15 @@
# Description:
# Portable 128-bit SIMD intrinsics
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
exports_files(["LICENSE"])
cc_library(
name = "psimd",
hdrs = glob(["include/psimd.h"]),
includes = ["include"],
strip_include_prefix = "include",
)

15
third_party/psimd/workspace.bzl vendored Normal file
View File

@ -0,0 +1,15 @@
"""Loads the psimd library, used by XNNPACK."""
load("//third_party:repo.bzl", "third_party_http_archive")
def repo():
third_party_http_archive(
name = "psimd",
strip_prefix = "psimd-8fd2884b88848180904a40c452a362d1ee429ad5",
sha256 = "9d4f05bc5a93a0ab8bcef12027ebe54cfddd0050d4862442449c8de11b4e8c17",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/Maratyszcza/psimd/archive/8fd2884b88848180904a40c452a362d1ee429ad5.tar.gz",
"https://github.com/Maratyszcza/psimd/archive/8fd2884b88848180904a40c452a362d1ee429ad5.tar.gz",
],
build_file = "//third_party/psimd:BUILD.bazel",
)

1
third_party/pthreadpool/BUILD vendored Normal file
View File

@ -0,0 +1 @@
# This empty BUILD file is required to make Bazel treat this directory as a package.

32
third_party/pthreadpool/BUILD.bazel vendored Normal file
View File

@ -0,0 +1,32 @@
# Description:
# Portable pthread-based thread pool for C and C++
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
exports_files(["LICENSE"])
cc_library(
name = "pthreadpool",
srcs = [
"src/threadpool-pthreads.c",
"src/threadpool-utils.h",
],
hdrs = [
"include/pthreadpool.h",
],
copts = [
"-O2",
],
defines = [
"PTHREADPOOL_NO_DEPRECATED_API",
],
includes = [
"include",
],
strip_include_prefix = "include",
deps = [
"@FXdiv",
],
)

15
third_party/pthreadpool/workspace.bzl vendored Normal file
View File

@ -0,0 +1,15 @@
"""Loads the pthreadpool library, used by XNNPACK."""
load("//third_party:repo.bzl", "third_party_http_archive")
def repo():
third_party_http_archive(
name = "pthreadpool",
strip_prefix = "pthreadpool-7ad026703b3109907ad124025918da15cfd3f100",
sha256 = "96eb4256fc438b7b8cab40541d383efaf546fae7bad380c24ea601c326c5f685",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/Maratyszcza/pthreadpool/archive/7ad026703b3109907ad124025918da15cfd3f100.tar.gz",
"https://github.com/Maratyszcza/pthreadpool/archive/7ad026703b3109907ad124025918da15cfd3f100.tar.gz",
],
build_file = "//third_party/pthreadpool:BUILD.bazel",
)