2022-09-22 12:26:48 -07:00
|
|
|
/* Copyright 2019 The JAX Authors.
|
2021-09-02 07:52:35 -07: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
|
|
|
|
|
|
|
|
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.
|
|
|
|
==============================================================================*/
|
|
|
|
|
2023-08-24 16:06:18 -07:00
|
|
|
#include "nanobind/nanobind.h"
|
2022-10-25 07:23:07 -07:00
|
|
|
#include "jaxlib/gpu/prng_kernels.h"
|
2023-08-24 16:06:18 -07:00
|
|
|
#include "jaxlib/kernel_nanobind_helpers.h"
|
2021-09-02 07:52:35 -07:00
|
|
|
|
|
|
|
namespace jax {
|
2022-10-25 07:23:07 -07:00
|
|
|
namespace JAX_GPU_NAMESPACE {
|
2021-09-02 07:52:35 -07:00
|
|
|
namespace {
|
|
|
|
|
2023-08-24 16:06:18 -07:00
|
|
|
namespace nb = nanobind;
|
|
|
|
|
2022-10-25 07:23:07 -07:00
|
|
|
std::string BuildThreeFry2x32Descriptor(std::int64_t n) {
|
2021-09-02 07:52:35 -07:00
|
|
|
return PackDescriptorAsString(ThreeFry2x32Descriptor{n});
|
|
|
|
}
|
2023-08-24 16:06:18 -07:00
|
|
|
nb::dict Registrations() {
|
|
|
|
nb::dict dict;
|
2024-06-28 06:24:01 -07:00
|
|
|
dict[JAX_GPU_PREFIX "_threefry2x32_ffi"] =
|
2024-07-10 12:08:30 -07:00
|
|
|
EncapsulateFfiHandler(ThreeFry2x32Ffi);
|
2024-07-31 08:09:28 -07:00
|
|
|
// TODO(b/338022728): remove after 6 months
|
2022-10-25 07:23:07 -07:00
|
|
|
dict[JAX_GPU_PREFIX "_threefry2x32"] = EncapsulateFunction(ThreeFry2x32);
|
2021-09-02 07:52:35 -07:00
|
|
|
return dict;
|
|
|
|
}
|
|
|
|
|
2023-08-24 16:06:18 -07:00
|
|
|
NB_MODULE(_prng, m) {
|
2021-09-02 07:52:35 -07:00
|
|
|
m.def("registrations", &Registrations);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
2022-10-25 07:23:07 -07:00
|
|
|
} // namespace JAX_GPU_NAMESPACE
|
2021-09-02 07:52:35 -07:00
|
|
|
} // namespace jax
|