Use Abseil Random library#118
Open
copybara-service[bot] wants to merge 1 commit intomainfrom
Open
Conversation
https://abseil.io/docs/cpp/guides/random Replace legacy C random functions (srand/rand) and time-based seeding with absl::BitGenRef and absl::Uniform. This provides better randomness properties and removes dependencies on global state. * **RandGen & RandEquivalent:** Update signatures to accept an `absl::BitGenRef` or an optional seed (`std::optional<uint64_t>`). When a seed is provided, it is used to initialize an internal bit generator. * **ArcSelector:** Update the `operator()` interface to require an `absl::BitGenRef`. This ensures that arc selection is driven by the caller's random source. * **WeightGenerator:** Standardize weight generation templates (e.g., `WeightGenerate<T>`) to take a bit generator. This allows for reproducible random weights in tests and FST generation. * **pywrapfst:** Change `randgen` and `randequivalent` to default to non-deterministic seeding (`seed=None`) instead of time-based seeding. PiperOrigin-RevId: 899501716
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use Abseil Random library
https://abseil.io/docs/cpp/guides/random
Replace legacy C random functions (srand/rand) and time-based seeding
with absl::BitGenRef and absl::Uniform. This provides better randomness
properties and removes dependencies on global state.
absl::BitGenRefor an optional seed (std::optional<uint64_t>).When a seed is provided, it is used to initialize an internal bit
generator.
operator()interface to require anabsl::BitGenRef. This ensures that arc selection is driven by thecaller's random source.
WeightGenerate<T>) to take a bit generator. This allows forreproducible random weights in tests and FST generation.
randgenandrandequivalentto default tonon-deterministic seeding (
seed=None) instead of time-based seeding.