rurand/distributions/
normal.rs1use ruda_kernel::dsl as kernel_dsl;
2use ruda_kernel::dsl::prelude::*;
3use ruda_kernel::library::tensor::View;
4use std::f32::consts::PI;
5
6use super::{PrngArgs, PrngRuntime, random};
7
8use crate::{RandomFamily, lcg_step, taus_step_0, taus_step_1, taus_step_2, to_unit_interval_open};
9
10#[derive(RudaLaunch, RudaType)]
11pub(crate) struct Normal {
12 mean: f32,
13 std: f32,
14}
15
16#[derive(Debug)]
17struct NormalFamily;
18
19impl RandomFamily for NormalFamily {
20 type Runtime = Normal;
21}
22
23impl PrngArgs for Normal {
24 type Args = Self;
25
26 fn args<R: Runtime>(self) -> NormalLaunch<R> {
27 NormalLaunch::new(self.mean, self.std)
28 }
29}
30
31pub fn random_normal<R: Runtime>(
33 client: &ComputeClient<R>,
34 mean: f32,
35 std: f32,
36 out: TensorBinding<R>,
37 dtype: StorageType,
38) -> Result<(), LaunchError> {
39 random::<NormalFamily, R>(client, Normal { mean, std }, out, dtype)
40}
41
42mod kernel;