Files
mlx/mlx/backend/cpu/threefry.h
Awni Hannun 1156c84e86 Refactor common into cpu specific and truly common (#1817)
* refactor

* fix extension example

* fix no-cpu
2025-02-03 15:58:02 -08:00

22 lines
572 B
C++

// Copyright © 2023 Apple Inc.
#pragma once
#include <cstdint>
#include <utility>
namespace mlx::core::random {
/** Applies the Threefry 2x32 hash function.
* This code is based on the Jax counter-based and splittable PRNG
* https://github.com/google/jax/blob/main/docs/jep/263-prng.md
*
* Original Threefry reference:
* http://www.thesalmons.org/john/random123/papers/random123sc11.pdf
*/
std::pair<uint32_t, uint32_t> threefry2x32_hash(
const std::pair<uint32_t, uint32_t>& key,
std::pair<uint32_t, uint32_t> count);
} // namespace mlx::core::random