2022-09-22 12:26:48 -07:00
|
|
|
# Copyright 2018 The JAX Authors.
|
2018-12-17 14:36:21 -05:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
# https://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.
|
|
|
|
|
|
|
|
# JAX is Autograd and XLA
|
|
|
|
|
2022-07-01 09:06:29 -07:00
|
|
|
load("//jaxlib:symlink_files.bzl", "symlink_files")
|
2021-01-20 14:05:54 -08:00
|
|
|
load(
|
2021-05-19 12:54:59 -07:00
|
|
|
"//jaxlib:jax.bzl",
|
2024-04-18 04:03:03 -07:00
|
|
|
"if_building_mosaic_gpu",
|
2023-03-27 10:14:05 -07:00
|
|
|
"py_library_providing_imports_info",
|
2021-01-20 14:05:54 -08:00
|
|
|
"pybind_extension",
|
2023-03-04 00:48:29 +00:00
|
|
|
"pytype_library",
|
2021-01-20 14:05:54 -08:00
|
|
|
)
|
2019-11-24 13:13:39 -05:00
|
|
|
|
2019-09-26 14:51:24 -07:00
|
|
|
licenses(["notice"])
|
2018-12-17 14:36:21 -05:00
|
|
|
|
2023-04-19 13:26:24 -07:00
|
|
|
package(
|
|
|
|
default_applicable_licenses = [],
|
|
|
|
default_visibility = ["//:__subpackages__"],
|
|
|
|
)
|
2018-12-17 14:36:21 -05:00
|
|
|
|
2024-05-10 12:55:17 -07:00
|
|
|
# This makes xla_extension module accessible from jax._src.lib.
|
|
|
|
genrule(
|
|
|
|
name = "xla_extension_py",
|
|
|
|
outs = ["xla_extension.py"],
|
|
|
|
cmd = "echo 'from xla.xla.python.xla_extension import *\n' > $@",
|
|
|
|
)
|
|
|
|
|
2023-03-27 10:14:05 -07:00
|
|
|
py_library_providing_imports_info(
|
2022-07-01 06:54:00 -07:00
|
|
|
name = "jaxlib",
|
|
|
|
srcs = [
|
2022-08-26 13:40:51 +00:00
|
|
|
"ducc_fft.py",
|
2023-09-11 16:13:09 -07:00
|
|
|
"gpu_common_utils.py",
|
2022-07-01 06:54:00 -07:00
|
|
|
"gpu_linalg.py",
|
|
|
|
"gpu_prng.py",
|
2022-11-28 14:31:10 -08:00
|
|
|
"gpu_rnn.py",
|
2022-07-01 06:54:00 -07:00
|
|
|
"gpu_solver.py",
|
|
|
|
"gpu_sparse.py",
|
2023-05-24 12:09:57 -07:00
|
|
|
"gpu_triton.py",
|
2022-12-15 20:59:34 -08:00
|
|
|
"hlo_helpers.py",
|
2022-07-01 06:54:00 -07:00
|
|
|
"init.py",
|
|
|
|
"lapack.py",
|
2022-07-01 09:06:29 -07:00
|
|
|
":version",
|
2022-07-01 12:31:16 -07:00
|
|
|
":xla_client",
|
2024-05-10 12:55:17 -07:00
|
|
|
":xla_extension_py",
|
2022-07-01 06:54:00 -07:00
|
|
|
],
|
2023-03-27 10:14:05 -07:00
|
|
|
lib_rule = pytype_library,
|
2022-07-01 06:54:00 -07:00
|
|
|
deps = [
|
|
|
|
":cpu_feature_guard",
|
2023-04-10 18:09:24 -07:00
|
|
|
":utils",
|
2022-10-24 10:02:12 -07:00
|
|
|
"//jaxlib/cpu:_ducc_fft",
|
|
|
|
"//jaxlib/cpu:_lapack",
|
2022-07-01 06:54:00 -07:00
|
|
|
"//jaxlib/mlir",
|
2024-01-11 06:20:16 -08:00
|
|
|
"//jaxlib/mlir:arithmetic_dialect",
|
2022-07-01 06:54:00 -07:00
|
|
|
"//jaxlib/mlir:builtin_dialect",
|
Migrate from MLIR-HLO's CHLO to StableHLO's CHLO
Unlike StableHLO which is meant to coexist with MHLO, StableHLO's CHLO is meant to replace MLIR-HLO's CHLO.
This change is the final step towards enabling adoption of StableHLO. If we keep two copies of CHLO, then some users won't be able to depend on both MLIR-HLO and StableHLO, and that is a useful possibility to enable both in the short and in the long term.
C++:
1) C++ dependency changes from `//third_party/tensorflow/compiler/xla/mlir_hlo` (includes CHLO, among other things) to `//third_party/tensorflow/compiler/xla/mlir_hlo/stablehlo:chlo_ops` (in CMake, from `ChloDialect` to `ChloOps`).
2) .h include changes from `#include "third_party/tensorflow/compiler/xla/mlir_hlo/include/mlir-hlo/Dialect/mhlo/IR/chlo_ops.h"` to `#include "third_party/tensorflow/compiler/xla/mlir_hlo/stablehlo/stablehlo/dialect/ChloOps.h"`.
3) To register the CHLO dialect in C++, you'll need to depend on `//third_party/tensorflow/compiler/xla/mlir_hlo/stablehlo:register`, include `#include "third_party/tensorflow/compiler/xla/mlir_hlo/stablehlo/stablehlo/dialect/Register.h"` and call `mlir::stablehlo::registerAllDialects(registry)`.
4) C++ usage doesn't change - StableHLO's CHLO is an exact copy of MLIR-HLO's CHLO.
Python:
5) Python dependency changes from `//third_party/py/mlir:mhlo_dialect` (includes CHLO, among other things) to `//third_party/py/mlir:chlo_dialect` (in CMake, from `MLIRHLOPythonModules` to `StablehloUnifiedPythonModules`).
6) Python imports don't change.
7) To register the CHLO dialect in Python, you'll need to change `chlo.register_chlo_dialect(context)` to `chlo.register_dialect(context)`.
8) Python usage doesn't change - StableHLO's CHLO is an exact copy of MLIR-HLO's CHLO.
PiperOrigin-RevId: 470265566
2022-08-26 09:34:46 -07:00
|
|
|
"//jaxlib/mlir:chlo_dialect",
|
2022-07-01 06:54:00 -07:00
|
|
|
"//jaxlib/mlir:func_dialect",
|
|
|
|
"//jaxlib/mlir:ir",
|
2024-01-11 06:20:16 -08:00
|
|
|
"//jaxlib/mlir:math_dialect",
|
2023-07-26 03:58:59 -07:00
|
|
|
"//jaxlib/mlir:memref_dialect",
|
2022-07-01 06:54:00 -07:00
|
|
|
"//jaxlib/mlir:mhlo_dialect",
|
|
|
|
"//jaxlib/mlir:pass_manager",
|
2023-07-26 03:58:59 -07:00
|
|
|
"//jaxlib/mlir:scf_dialect",
|
2022-07-01 06:54:00 -07:00
|
|
|
"//jaxlib/mlir:sparse_tensor_dialect",
|
Migrate from MLIR-HLO's CHLO to StableHLO's CHLO
Unlike StableHLO which is meant to coexist with MHLO, StableHLO's CHLO is meant to replace MLIR-HLO's CHLO.
This change is the final step towards enabling adoption of StableHLO. If we keep two copies of CHLO, then some users won't be able to depend on both MLIR-HLO and StableHLO, and that is a useful possibility to enable both in the short and in the long term.
C++:
1) C++ dependency changes from `//third_party/tensorflow/compiler/xla/mlir_hlo` (includes CHLO, among other things) to `//third_party/tensorflow/compiler/xla/mlir_hlo/stablehlo:chlo_ops` (in CMake, from `ChloDialect` to `ChloOps`).
2) .h include changes from `#include "third_party/tensorflow/compiler/xla/mlir_hlo/include/mlir-hlo/Dialect/mhlo/IR/chlo_ops.h"` to `#include "third_party/tensorflow/compiler/xla/mlir_hlo/stablehlo/stablehlo/dialect/ChloOps.h"`.
3) To register the CHLO dialect in C++, you'll need to depend on `//third_party/tensorflow/compiler/xla/mlir_hlo/stablehlo:register`, include `#include "third_party/tensorflow/compiler/xla/mlir_hlo/stablehlo/stablehlo/dialect/Register.h"` and call `mlir::stablehlo::registerAllDialects(registry)`.
4) C++ usage doesn't change - StableHLO's CHLO is an exact copy of MLIR-HLO's CHLO.
Python:
5) Python dependency changes from `//third_party/py/mlir:mhlo_dialect` (includes CHLO, among other things) to `//third_party/py/mlir:chlo_dialect` (in CMake, from `MLIRHLOPythonModules` to `StablehloUnifiedPythonModules`).
6) Python imports don't change.
7) To register the CHLO dialect in Python, you'll need to change `chlo.register_chlo_dialect(context)` to `chlo.register_dialect(context)`.
8) Python usage doesn't change - StableHLO's CHLO is an exact copy of MLIR-HLO's CHLO.
PiperOrigin-RevId: 470265566
2022-08-26 09:34:46 -07:00
|
|
|
"//jaxlib/mlir:stablehlo_dialect",
|
2024-01-11 06:20:16 -08:00
|
|
|
"//jaxlib/mlir:vector_dialect",
|
|
|
|
"//jaxlib/mosaic",
|
2024-01-16 14:20:58 +00:00
|
|
|
"//jaxlib/triton",
|
2024-05-10 12:55:17 -07:00
|
|
|
"@xla//xla/python:xla_extension",
|
2024-04-18 04:03:03 -07:00
|
|
|
] + if_building_mosaic_gpu(["//jaxlib/mosaic/gpu:mosaic_gpu"]),
|
2022-07-01 06:54:00 -07:00
|
|
|
)
|
|
|
|
|
2022-07-01 09:06:29 -07:00
|
|
|
symlink_files(
|
|
|
|
name = "version",
|
|
|
|
srcs = ["//jax:version.py"],
|
|
|
|
dst = ".",
|
|
|
|
flatten = True,
|
|
|
|
)
|
|
|
|
|
2022-07-01 12:31:16 -07:00
|
|
|
symlink_files(
|
|
|
|
name = "xla_client",
|
2023-03-13 14:35:56 -07:00
|
|
|
srcs = ["@xla//xla/python:xla_client"],
|
2022-07-01 12:31:16 -07:00
|
|
|
dst = ".",
|
|
|
|
flatten = True,
|
|
|
|
)
|
|
|
|
|
2022-07-01 06:54:00 -07:00
|
|
|
exports_files([
|
2022-07-13 14:03:32 -07:00
|
|
|
"README.md",
|
2022-07-01 06:54:00 -07:00
|
|
|
"setup.py",
|
|
|
|
])
|
|
|
|
|
2019-12-05 18:59:29 -08:00
|
|
|
cc_library(
|
2023-08-24 16:06:18 -07:00
|
|
|
name = "absl_status_casters",
|
|
|
|
hdrs = ["absl_status_casters.h"],
|
|
|
|
copts = [
|
|
|
|
"-fexceptions",
|
|
|
|
"-fno-strict-aliasing",
|
|
|
|
],
|
|
|
|
features = ["-use_header_modules"],
|
|
|
|
deps = [
|
|
|
|
"@com_google_absl//absl/status",
|
|
|
|
"@com_google_absl//absl/status:statusor",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "kernel_nanobind_helpers",
|
|
|
|
hdrs = ["kernel_nanobind_helpers.h"],
|
2019-12-05 18:59:29 -08:00
|
|
|
copts = [
|
|
|
|
"-fexceptions",
|
|
|
|
"-fno-strict-aliasing",
|
|
|
|
],
|
|
|
|
features = ["-use_header_modules"],
|
|
|
|
deps = [
|
|
|
|
":kernel_helpers",
|
2024-03-29 13:05:35 -07:00
|
|
|
"@xla//xla/tsl/python/lib/core:numpy",
|
2020-10-23 14:20:06 -07:00
|
|
|
"@com_google_absl//absl/base",
|
2023-08-24 16:06:18 -07:00
|
|
|
"@nanobind",
|
2019-12-05 18:59:29 -08:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-11-24 13:06:23 -05:00
|
|
|
cc_library(
|
|
|
|
name = "kernel_helpers",
|
|
|
|
hdrs = ["kernel_helpers.h"],
|
|
|
|
copts = [
|
|
|
|
"-fexceptions",
|
|
|
|
"-fno-strict-aliasing",
|
|
|
|
],
|
2019-11-26 17:06:57 -08:00
|
|
|
features = ["-use_header_modules"],
|
2019-11-24 13:06:23 -05:00
|
|
|
deps = [
|
|
|
|
"@com_google_absl//absl/base",
|
2021-08-09 15:06:12 -07:00
|
|
|
"@com_google_absl//absl/status:statusor",
|
2019-11-24 13:06:23 -05:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-11-25 11:48:45 -05:00
|
|
|
cc_library(
|
2020-12-05 02:02:57 +01:00
|
|
|
name = "handle_pool",
|
|
|
|
hdrs = ["handle_pool.h"],
|
|
|
|
copts = [
|
|
|
|
"-fexceptions",
|
|
|
|
"-fno-strict-aliasing",
|
|
|
|
],
|
|
|
|
features = ["-use_header_modules"],
|
|
|
|
deps = [
|
2021-01-20 09:38:55 -05:00
|
|
|
"@com_google_absl//absl/base:core_headers",
|
2021-08-09 15:06:12 -07:00
|
|
|
"@com_google_absl//absl/status:statusor",
|
2021-01-20 09:38:55 -05:00
|
|
|
"@com_google_absl//absl/synchronization",
|
2020-12-05 02:02:57 +01:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2022-10-24 10:02:12 -07:00
|
|
|
# This isn't a CPU kernel. This exists to catch cases where jaxlib is built for the wrong
|
|
|
|
# target architecture.
|
2021-09-03 10:03:25 -07:00
|
|
|
pybind_extension(
|
|
|
|
name = "cpu_feature_guard",
|
|
|
|
srcs = ["cpu_feature_guard.c"],
|
|
|
|
module_name = "cpu_feature_guard",
|
|
|
|
deps = [
|
2023-02-14 21:24:27 +00:00
|
|
|
"@xla//third_party/python_runtime:headers",
|
2021-09-03 10:03:25 -07:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2023-04-10 18:09:24 -07:00
|
|
|
pybind_extension(
|
|
|
|
name = "utils",
|
|
|
|
srcs = ["utils.cc"],
|
|
|
|
module_name = "utils",
|
|
|
|
deps = [
|
|
|
|
"@xla//third_party/python_runtime:headers",
|
|
|
|
"@com_google_absl//absl/cleanup",
|
|
|
|
"@com_google_absl//absl/container:inlined_vector",
|
2023-08-24 16:06:18 -07:00
|
|
|
"@nanobind",
|
2023-04-10 18:09:24 -07:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2023-09-25 10:51:12 -07:00
|
|
|
pybind_extension(
|
|
|
|
name = "cuda_plugin_extension",
|
|
|
|
srcs = ["cuda_plugin_extension.cc"],
|
|
|
|
module_name = "cuda_plugin_extension",
|
|
|
|
deps = [
|
2023-09-26 15:53:31 -07:00
|
|
|
"@nanobind",
|
|
|
|
"//jaxlib:kernel_nanobind_helpers",
|
2023-09-25 10:51:12 -07:00
|
|
|
"@xla//third_party/python_runtime:headers",
|
|
|
|
"@xla//xla:status",
|
2024-04-30 12:49:57 -07:00
|
|
|
"@local_config_cuda//cuda:cuda_headers",
|
2023-09-25 10:51:12 -07:00
|
|
|
"@xla//xla:util",
|
2024-03-04 14:07:56 -08:00
|
|
|
"@xla//xla/pjrt:status_casters",
|
2023-09-25 10:51:12 -07:00
|
|
|
"@xla//xla/pjrt/c:pjrt_c_api_gpu_extension_hdrs",
|
|
|
|
"@xla//xla/pjrt/c:pjrt_c_api_hdrs",
|
|
|
|
"@xla//xla/pjrt/c:pjrt_c_api_helpers",
|
2023-09-26 15:53:31 -07:00
|
|
|
# TODO(jieying): move to jaxlib after py_client_gpu is separated from py_client
|
|
|
|
"@xla//xla/python:py_client_gpu",
|
2024-02-26 15:44:20 -08:00
|
|
|
"@xla//xla/tsl/cuda:cublas",
|
|
|
|
"@xla//xla/tsl/cuda:cudart",
|
2024-03-29 13:05:35 -07:00
|
|
|
"@xla//xla/tsl/python/lib/core:numpy",
|
2023-09-25 10:51:12 -07:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2022-10-24 10:02:12 -07:00
|
|
|
# CPU kernels
|
2021-09-03 10:03:25 -07:00
|
|
|
|
2022-10-24 10:02:12 -07:00
|
|
|
# TODO(phawkins): Remove this forwarding target.
|
2021-09-03 10:03:25 -07:00
|
|
|
cc_library(
|
|
|
|
name = "cpu_kernels",
|
2022-04-28 10:45:35 -07:00
|
|
|
visibility = ["//visibility:public"],
|
2021-09-03 10:03:25 -07:00
|
|
|
deps = [
|
2022-10-24 10:02:12 -07:00
|
|
|
"//jaxlib/cpu:cpu_kernels",
|
2021-09-03 10:03:25 -07:00
|
|
|
],
|
|
|
|
alwayslink = 1,
|
|
|
|
)
|
|
|
|
|
2022-05-06 13:47:23 -07:00
|
|
|
# TODO(phawkins): Remove this forwarding target.
|
2021-09-02 07:52:35 -07:00
|
|
|
cc_library(
|
|
|
|
name = "gpu_kernels",
|
2022-04-28 10:45:35 -07:00
|
|
|
visibility = ["//visibility:public"],
|
2021-09-02 07:52:35 -07:00
|
|
|
deps = [
|
2022-05-06 13:47:23 -07:00
|
|
|
"//jaxlib/cuda:cuda_gpu_kernels",
|
2021-09-02 07:52:35 -07:00
|
|
|
],
|
2021-09-03 10:03:25 -07:00
|
|
|
alwayslink = 1,
|
2021-09-02 07:52:35 -07:00
|
|
|
)
|