本文主要是介绍Bazel离线编译SPU,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
本文介绍如何离线编译隐语的spu库,前提是依赖都已经下载好。
主要使用
load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
以及http_archive中的url可以指定为本地地址。下面给出/spu/bazel/repositories.bzl示例。
# Copyright 2021 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")def spu_deps():_rules_cuda()_rules_proto_grpc()_bazel_platform()_com_github_xtensor_xtensor()_com_github_xtensor_xtl()_com_github_openxla_xla()_com_github_pybind11_bazel()_com_github_pybind11()_com_intel_hexl()_com_github_emptoolkit_emp_tool()_com_github_emptoolkit_emp_ot()_com_github_facebook_zstd()_com_github_microsoft_seal()_com_github_eigenteam_eigen()_com_github_nvidia_cutlass()_yacl()_libpsi()def _yacl():local_repository(name = "yacl",path = "/repository/yacl",)def _libpsi():maybe(http_archive,name = "psi",urls = ["file:///repository/psi-0.4.0.dev240401.tar.gz","https://github.com/secretflow/psi/archive/refs/tags/v0.4.0.dev240401.tar.gz",],strip_prefix = "psi-0.4.0.dev240401",sha256 = "bc91e5c635fc94f865004e61e3896eb334d76549c1125fbc98caf8c6b3a82463",)def _rules_proto_grpc():http_archive(name = "rules_proto_grpc",sha256 = "2a0860a336ae836b54671cbbe0710eec17c64ef70c4c5a88ccfd47ea6e3739bd",strip_prefix = "rules_proto_grpc-4.6.0",urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/releases/download/4.6.0/rules_proto_grpc-4.6.0.tar.gz",],)def _rules_cuda():http_archive(name = "rules_cuda",sha256 = "2f8c8c8c85f727bec4423efecec12d3b751cb0a98bda99f0f9d351608a23b858",strip_prefix = "rules_cuda-v0.2.1",urls = ["https://github.com/bazel-contrib/rules_cuda/releases/download/v0.2.1/rules_cuda-v0.2.1.tar.gz"],)def _bazel_platform():http_archive(name = "platforms",urls = ["file:///repository/platforms-0.0.9.tar.gz","https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz","https://github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz",],sha256 = "5eda539c841265031c2f82d8ae7a3a6490bd62176e0c038fc469eabf91f6149b",)def _com_github_facebook_zstd():maybe(http_archive,name = "com_github_facebook_zstd",build_file = "@spulib//bazel:zstd.BUILD",strip_prefix = "zstd-1.5.6",sha256 = "30f35f71c1203369dc979ecde0400ffea93c27391bfd2ac5a9715d2173d92ff7",type = ".tar.gz",urls = ["file:///repository/zstd-v1.5.6.tar.gz","https://github.com/facebook/zstd/archive/refs/tags/v1.5.6.tar.gz",],)def _com_github_xtensor_xtensor():maybe(http_archive,name = "com_github_xtensor_xtensor",sha256 = "32d5d9fd23998c57e746c375a544edf544b74f0a18ad6bc3c38cbba968d5e6c7",strip_prefix = "xtensor-0.25.0",build_file = "@spulib//bazel:xtensor.BUILD",type = "tar.gz",urls = ["https://github.com/xtensor-stack/xtensor/archive/refs/tags/0.25.0.tar.gz",],)def _com_github_xtensor_xtl():maybe(http_archive,name = "com_github_xtensor_xtl",sha256 = "44fb99fbf5e56af5c43619fc8c29aa58e5fad18f3ba6e7d9c55c111b62df1fbb",strip_prefix = "xtl-0.7.7",build_file = "@spulib//bazel:xtl.BUILD",type = "tar.gz",urls = ["https://github.com/xtensor-stack/xtl/archive/refs/tags/0.7.7.tar.gz",],)def _com_github_openxla_xla():OPENXLA_COMMIT = "c408b6320bbf8407b781487a2dbe329cb7488dac"OPENXLA_SHA256 = "77297f7f3a8796e865d2704ad595be05f87f9bb495121dd8904121320aec5601"# We need openxla to handle xla/mhlo/stablehlomaybe(http_archive,name = "xla",sha256 = OPENXLA_SHA256,strip_prefix = "xla-" + OPENXLA_COMMIT,type = ".tar.gz",urls = ["file:///repository/xla-c408b6320bbf8407b781487a2dbe329cb7488dac.tar.gz","https://github.com/openxla/xla/archive/{commit}.tar.gz".format(commit = OPENXLA_COMMIT),],)def _com_github_pybind11_bazel():maybe(http_archive,name = "pybind11_bazel",sha256 = "dc4882b23a617575d0fd822aba88aa4a14133c3d428b5a8fb83d81d03444a475",strip_prefix = "pybind11_bazel-8889d39b2b925b2a47519ae09402a96f00ccf2b4",urls = ["https://github.com/pybind/pybind11_bazel/archive/8889d39b2b925b2a47519ae09402a96f00ccf2b4.zip",],)def _com_github_pybind11():maybe(http_archive,name = "pybind11",build_file = "@pybind11_bazel//:pybind11.BUILD",sha256 = "bf8f242abd1abcd375d516a7067490fb71abd79519a282d22b6e4d19282185a7",strip_prefix = "pybind11-2.12.0",urls = ["file:///repository/pybind-v2.12.0.tar.gz","https://github.com/pybind/pybind11/archive/refs/tags/v2.12.0.tar.gz",],)def _com_intel_hexl():maybe(http_archive,name = "com_intel_hexl",type = "tar.gz",strip_prefix = "hexl-1.2.5",sha256 = "3692e6e6183dbc49253e51e86c3e52e7affcac925f57db0949dbb4d34b558a9a",build_file = "@spulib//bazel:hexl.BUILD",urls = ["https://github.com/intel/hexl/archive/refs/tags/v1.2.5.tar.gz",],patch_args = ["-p1"],patches = ["@spulib//bazel:patches/hexl.patch"],)def _com_github_emptoolkit_emp_tool():maybe(http_archive,name = "com_github_emptoolkit_emp_tool",sha256 = "b9ab2380312e78020346b5d2db3d0244c7bd8098cb50f8b3620532ef491808d0",strip_prefix = "emp-tool-0.2.5",type = "tar.gz",patch_args = ["-p1"],patches = ["@spulib//bazel:patches/emp-tool.patch","@spulib//bazel:patches/emp-tool-cmake.patch","@spulib//bazel:patches/emp-tool-sse2neon.patch",],urls = ["https://github.com/emp-toolkit/emp-tool/archive/refs/tags/0.2.5.tar.gz",],build_file = "@spulib//bazel:emp-tool.BUILD",)def _com_github_emptoolkit_emp_ot():maybe(http_archive,name = "com_github_emptoolkit_emp_ot",sha256 = "358036e5d18143720ee17103f8172447de23014bcfc1f8e7d5849c525ca928ac",strip_prefix = "emp-ot-0.2.4",type = "tar.gz",patch_args = ["-p1"],patches = ["@spulib//bazel:patches/emp-ot.patch"],urls = ["https://github.com/emp-toolkit/emp-ot/archive/refs/tags/0.2.4.tar.gz",],build_file = "@spulib//bazel:emp-ot.BUILD",)def _com_github_microsoft_seal():maybe(http_archive,name = "com_github_microsoft_seal",sha256 = "af9bf0f0daccda2a8b7f344f13a5692e0ee6a45fea88478b2b90c35648bf2672",strip_prefix = "SEAL-4.1.1",type = "tar.gz",patch_args = ["-p1"],patches = ["@spulib//bazel:patches/seal.patch"],urls = ["https://github.com/microsoft/SEAL/archive/refs/tags/v4.1.1.tar.gz",],build_file = "@spulib//bazel:seal.BUILD",)def _com_github_eigenteam_eigen():EIGEN_COMMIT = "66e8f38891841bf88ee976a316c0c78a52f0cee5"EIGEN_SHA256 = "01fcd68409c038bbcfd16394274c2bf71e2bb6dda89a2319e23fc59a2da17210"maybe(http_archive,name = "com_github_eigenteam_eigen",sha256 = EIGEN_SHA256,build_file = "@spulib//bazel:eigen.BUILD",strip_prefix = "eigen-{commit}".format(commit = EIGEN_COMMIT),urls = ["https://gitlab.com/libeigen/eigen/-/archive/{commit}/eigen-{commit}.tar.gz".format(commit = EIGEN_COMMIT),],)def _com_github_nvidia_cutlass():maybe(http_archive,name = "com_github_nvidia_cutlass",strip_prefix = "cutlass-3.5.0",urls = ["file:///repository/cutlass-v3.5.0.tar.gz","https://github.com/NVIDIA/cutlass/archive/refs/tags/v3.5.0.tar.gz",],sha256 = "ef6af8526e3ad04f9827f35ee57eec555d09447f70a0ad0cf684a2e426ccbcb6",build_file = "@spulib//bazel:nvidia_cutlass.BUILD",)
这篇关于Bazel离线编译SPU的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!