Utilities Module
The bayes_hdc.utils module provides utility functions.
-
bayes_hdc.utils.normalize(x, axis=-1, eps=1e-08)[source]
Normalize vectors to unit length.
- Parameters:
-
- Return type:
Array
-
bayes_hdc.utils.benchmark_function(fn, *args, num_trials=100, warmup=10, **kwargs)[source]
Benchmark a JAX function with proper warmup and async handling.
- Parameters:
fn (Callable[[...], Any]) – Function to benchmark
*args (Any) – Positional arguments to fn
num_trials (int) – Number of trials to run
warmup (int) – Number of warmup trials
**kwargs (Any) – Keyword arguments to fn
- Returns:
Dictionary with timing statistics (mean, std, min, max, median in ms)
- Return type:
dict[str, float | int]