Skip to main content

RandomPlan

Struct RandomPlan 

Source
pub struct RandomPlan<T: Element, const N: usize> { /* private fields */ }
Expand description

Random-generator plan.

Generic on T so the same type can carry the FP generators (RandomPlan<f32, N>, RandomPlan<f64, N>) and the Bernoulli generator (RandomPlan<Bool, N>). The element kind is reasserted in select() against the descriptor.

The plan owns a single cuRAND generator handle, created lazily on the first call to run (or any of the typed run_* accessors). cuRAND generators are not thread-safe; the plan is !Sync and !Send as a consequence (the Cell<curandGenerator_t> makes both negative).

Implementations§

Source§

impl<T: Element, const N: usize> RandomPlan<T, N>

Source

pub fn select( _stream: &Stream, desc: &RandomDescriptor<N>, _pref: PlanPreference, ) -> Result<Self>

Pick a kernel + validate the descriptor.

Source

pub fn workspace_size(&self) -> usize

Workspace size in bytes.

Bernoulli needs numel * sizeof(f32) bytes for the uniform-rand intermediate buffer cuRAND writes into. Uniform / Normal need zero — cuRAND writes directly to the caller-provided output.

Source

pub fn sku(&self) -> KernelSku

Kernel SKU identity.

Source

pub fn precision_guarantee(&self) -> PrecisionGuarantee

Numerical guarantees.

Source§

impl<const N: usize> RandomPlan<f32, N>

Source

pub fn run( &self, stream: &Stream, _workspace: Workspace<'_>, args: RandomArgs<'_, f32, N>, ) -> Result<()>

Generate Uniform(low, high) or Normal(mean, stddev) f32 samples.

Source§

impl<const N: usize> RandomPlan<f64, N>

Source

pub fn run( &self, stream: &Stream, _workspace: Workspace<'_>, args: RandomArgs<'_, f64, N>, ) -> Result<()>

Generate Uniform(low, high) or Normal(mean, stddev) f64 samples.

Source§

impl<const N: usize> RandomPlan<Bool, N>

Source

pub fn run( &self, stream: &Stream, workspace: Workspace<'_>, args: RandomBoolArgs<'_, N>, ) -> Result<()>

Generate a Bernoulli(p) sample tensor.

Trait Implementations§

Source§

impl<T: Element, const N: usize> Drop for RandomPlan<T, N>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<T, const N: usize> !Freeze for RandomPlan<T, N>

§

impl<T, const N: usize> !RefUnwindSafe for RandomPlan<T, N>

§

impl<T, const N: usize> !Send for RandomPlan<T, N>

§

impl<T, const N: usize> !Sync for RandomPlan<T, N>

§

impl<T, const N: usize> Unpin for RandomPlan<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnsafeUnpin for RandomPlan<T, N>

§

impl<T, const N: usize> UnwindSafe for RandomPlan<T, N>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.