mirror of
https://github.com/ROCm/jax.git
synced 2025-04-17 12:26:07 +00:00

See https://opensource.google/documentation/reference/releasing/contributions#copyright for more details. PiperOrigin-RevId: 476167538
279 lines
7.7 KiB
Python
279 lines
7.7 KiB
Python
# Copyright 2018 The JAX Authors.
|
|
#
|
|
# 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.
|
|
|
|
# AMD HIP kernels
|
|
|
|
load(
|
|
"//jaxlib:jax.bzl",
|
|
"if_rocm_is_configured",
|
|
"pybind_extension",
|
|
"rocm_library",
|
|
)
|
|
|
|
licenses(["notice"])
|
|
|
|
package(default_visibility = ["//:__subpackages__"])
|
|
|
|
|
|
cc_library(
|
|
name = "hip_gpu_kernel_helpers",
|
|
srcs = if_rocm_is_configured(["hip_gpu_kernel_helpers.cc"]),
|
|
hdrs = if_rocm_is_configured(["hip_gpu_kernel_helpers.h"]),
|
|
copts = [
|
|
"-fexceptions",
|
|
],
|
|
features = ["-use_header_modules"],
|
|
deps = [
|
|
"@com_google_absl//absl/memory",
|
|
"@com_google_absl//absl/status",
|
|
"@com_google_absl//absl/status:statusor",
|
|
"@com_google_absl//absl/strings",
|
|
] + if_rocm_is_configured([
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
]),
|
|
)
|
|
|
|
cc_library(
|
|
name = "hipblas_kernels",
|
|
srcs = ["hipblas_kernels.cc"],
|
|
hdrs = ["hipblas_kernels.h"],
|
|
deps = [
|
|
"//jaxlib:handle_pool",
|
|
":hip_gpu_kernel_helpers",
|
|
"//jaxlib:kernel_helpers",
|
|
"@com_google_absl//absl/algorithm:container",
|
|
"@com_google_absl//absl/base",
|
|
"@com_google_absl//absl/base:core_headers",
|
|
"@com_google_absl//absl/hash",
|
|
"@com_google_absl//absl/memory",
|
|
"@com_google_absl//absl/status",
|
|
"@com_google_absl//absl/strings",
|
|
"@com_google_absl//absl/strings:str_format",
|
|
"@com_google_absl//absl/synchronization",
|
|
"@local_config_rocm//rocm:hipblas",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@org_tensorflow//tensorflow/compiler/xla/service:custom_call_status",
|
|
],
|
|
)
|
|
|
|
pybind_extension(
|
|
name = "_hipblas",
|
|
srcs = ["hipblas.cc"],
|
|
copts = [
|
|
"-fexceptions",
|
|
"-fno-strict-aliasing",
|
|
],
|
|
features = ["-use_header_modules"],
|
|
module_name = "_hipblas",
|
|
deps = [
|
|
":hipblas_kernels",
|
|
"//jaxlib:kernel_pybind11_helpers",
|
|
"@com_google_absl//absl/container:flat_hash_map",
|
|
"@com_google_absl//absl/strings:str_format",
|
|
"@local_config_rocm//rocm:hipblas",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@pybind11",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "hipsolver_kernels",
|
|
srcs = ["hipsolver_kernels.cc"],
|
|
hdrs = ["hipsolver_kernels.h"],
|
|
deps = [
|
|
"//jaxlib:handle_pool",
|
|
":hip_gpu_kernel_helpers",
|
|
"//jaxlib:kernel_helpers",
|
|
"@com_google_absl//absl/status",
|
|
"@com_google_absl//absl/status:statusor",
|
|
"@com_google_absl//absl/synchronization",
|
|
"@local_config_rocm//rocm:hipsolver",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@org_tensorflow//tensorflow/compiler/xla/service:custom_call_status",
|
|
],
|
|
)
|
|
|
|
pybind_extension(
|
|
name = "_hipsolver",
|
|
srcs = ["hipsolver.cc"],
|
|
copts = [
|
|
"-fexceptions",
|
|
"-fno-strict-aliasing",
|
|
],
|
|
features = ["-use_header_modules"],
|
|
module_name = "_hipsolver",
|
|
deps = [
|
|
":hip_gpu_kernel_helpers",
|
|
":hipsolver_kernels",
|
|
"//jaxlib:kernel_pybind11_helpers",
|
|
"@com_google_absl//absl/container:flat_hash_map",
|
|
"@com_google_absl//absl/strings:str_format",
|
|
"@local_config_rocm//rocm:hipsolver",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@pybind11",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "hipsparse_kernels",
|
|
srcs = ["hipsparse_kernels.cc"],
|
|
hdrs = ["hipsparse_kernels.h"],
|
|
deps = [
|
|
"//jaxlib:handle_pool",
|
|
":hip_gpu_kernel_helpers",
|
|
"//jaxlib:kernel_helpers",
|
|
"@com_google_absl//absl/status",
|
|
"@com_google_absl//absl/status:statusor",
|
|
"@com_google_absl//absl/synchronization",
|
|
"@local_config_rocm//rocm:hipsparse",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@org_tensorflow//tensorflow/compiler/xla/service:custom_call_status",
|
|
],
|
|
)
|
|
|
|
pybind_extension(
|
|
name = "_hipsparse",
|
|
srcs = ["hipsparse.cc"],
|
|
copts = [
|
|
"-fexceptions",
|
|
"-fno-strict-aliasing",
|
|
],
|
|
features = ["-use_header_modules"],
|
|
module_name = "_hipsparse",
|
|
deps = [
|
|
":hip_gpu_kernel_helpers",
|
|
":hipsparse_kernels",
|
|
"//jaxlib:kernel_pybind11_helpers",
|
|
"@com_google_absl//absl/algorithm:container",
|
|
"@com_google_absl//absl/base",
|
|
"@com_google_absl//absl/base:core_headers",
|
|
"@com_google_absl//absl/container:flat_hash_map",
|
|
"@com_google_absl//absl/hash",
|
|
"@com_google_absl//absl/memory",
|
|
"@com_google_absl//absl/strings",
|
|
"@com_google_absl//absl/strings:str_format",
|
|
"@com_google_absl//absl/synchronization",
|
|
"@local_config_rocm//rocm:hipsparse",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@pybind11",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "hip_lu_pivot_kernels",
|
|
srcs = [
|
|
"hip_lu_pivot_kernels.cc",
|
|
],
|
|
hdrs = ["hip_lu_pivot_kernels.h"],
|
|
deps = [
|
|
":hip_gpu_kernel_helpers",
|
|
":hip_lu_pivot_kernels_impl",
|
|
"//jaxlib:kernel_helpers",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@org_tensorflow//tensorflow/compiler/xla/service:custom_call_status",
|
|
],
|
|
)
|
|
|
|
rocm_library(
|
|
name = "hip_lu_pivot_kernels_impl",
|
|
srcs = [
|
|
"hip_lu_pivot_kernels.hip.cc",
|
|
],
|
|
hdrs = ["hip_lu_pivot_kernels.h"],
|
|
deps = [
|
|
":hip_gpu_kernel_helpers",
|
|
"//jaxlib:kernel_helpers",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@org_tensorflow//tensorflow/compiler/xla/service:custom_call_status",
|
|
],
|
|
)
|
|
|
|
pybind_extension(
|
|
name = "_hip_linalg",
|
|
srcs = ["hip_linalg.cc"],
|
|
copts = [
|
|
"-fexceptions",
|
|
"-fno-strict-aliasing",
|
|
],
|
|
features = ["-use_header_modules"],
|
|
module_name = "_hip_linalg",
|
|
deps = [
|
|
":hip_gpu_kernel_helpers",
|
|
":hip_lu_pivot_kernels",
|
|
":hip_lu_pivot_kernels_impl",
|
|
"//jaxlib:kernel_pybind11_helpers",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@pybind11",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "hip_prng_kernels",
|
|
srcs = [
|
|
"hip_prng_kernels.cc",
|
|
],
|
|
hdrs = ["hip_prng_kernels.h"],
|
|
deps = [
|
|
":hip_gpu_kernel_helpers",
|
|
":hip_prng_kernels_impl",
|
|
"//jaxlib:kernel_helpers",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@org_tensorflow//tensorflow/compiler/xla/service:custom_call_status",
|
|
],
|
|
)
|
|
|
|
rocm_library(
|
|
name = "hip_prng_kernels_impl",
|
|
srcs = [
|
|
"hip_prng_kernels.hip.cc",
|
|
],
|
|
hdrs = ["hip_prng_kernels.h"],
|
|
deps = [
|
|
":hip_gpu_kernel_helpers",
|
|
"//jaxlib:kernel_helpers",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@org_tensorflow//tensorflow/compiler/xla/service:custom_call_status",
|
|
],
|
|
)
|
|
|
|
pybind_extension(
|
|
name = "_hip_prng",
|
|
srcs = ["hip_prng.cc"],
|
|
copts = [
|
|
"-fexceptions",
|
|
"-fno-strict-aliasing",
|
|
],
|
|
features = ["-use_header_modules"],
|
|
module_name = "_hip_prng",
|
|
deps = [
|
|
":hip_gpu_kernel_helpers",
|
|
":hip_prng_kernels",
|
|
"//jaxlib:kernel_pybind11_helpers",
|
|
"@local_config_rocm//rocm:rocm_headers",
|
|
"@pybind11",
|
|
],
|
|
)
|
|
|
|
py_library(
|
|
name = "rocm_gpu_support",
|
|
deps = [
|
|
":_hip_linalg",
|
|
":_hip_prng",
|
|
":_hipblas",
|
|
":_hipsolver",
|
|
":_hipsparse",
|
|
],
|
|
)
|
|
|