pub struct TestInputBuilder { /* private fields */ }Expand description
Fluent builder for TestInput.
Use TestInput::builder to start one. The builder holds the shape,
dtype, and stride spec. Call a finalizer (arange, eye, zeros,
uniform, bernoulli, random, custom) to produce a TestInput
ready to generate a tensor handle, host data, or test tensor.
§Example
ⓘ
use cubek_test_utils::{TestInput, StrideSpec, Distribution};
let (handle, host) = TestInput::builder(client, [4, 4])
.stride(StrideSpec::ColMajor)
.uniform( 0, -1.0, 1.0)
.generate_with_f32_host_data();Implementations§
Source§impl TestInputBuilder
impl TestInputBuilder
Sourcepub fn dtype(self, dtype: impl Into<InputDataType>) -> Self
pub fn dtype(self, dtype: impl Into<InputDataType>) -> Self
Override the dtype. Defaults to f32.
Sourcepub fn stride(self, stride_spec: StrideSpec) -> Self
pub fn stride(self, stride_spec: StrideSpec) -> Self
Override the stride layout. Defaults to StrideSpec::RowMajor.
Sourcepub fn arange_scaled(self, scale: f32) -> TestInput
pub fn arange_scaled(self, scale: f32) -> TestInput
arange with each value multiplied by scale.
Sourcepub fn random(self, seed: u64, distribution: Distribution) -> TestInput
pub fn random(self, seed: u64, distribution: Distribution) -> TestInput
Random tensor with a custom Distribution.
Sourcepub fn bernoulli(self, seed: u64, p: f32) -> TestInput
pub fn bernoulli(self, seed: u64, p: f32) -> TestInput
Bernoulli random with probability p of 1.
Sourcepub fn normal(self, seed: u64, mean: f32, std: f32) -> TestInput
pub fn normal(self, seed: u64, mean: f32, std: f32) -> TestInput
Normal (Gaussian) random with the given mean and std.
Auto Trait Implementations§
impl Freeze for TestInputBuilder
impl !RefUnwindSafe for TestInputBuilder
impl Send for TestInputBuilder
impl Sync for TestInputBuilder
impl Unpin for TestInputBuilder
impl UnsafeUnpin for TestInputBuilder
impl !UnwindSafe for TestInputBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more