rstsr_core/storage/
assignment.rs

1//! Data assignments on device
2
3use crate::prelude_dev::*;
4
5pub trait OpAssignArbitaryAPI<TC, DC, DA, TA = TC>
6where
7    DC: DimAPI,
8    DA: DimAPI,
9    Self: DeviceRawAPI<TA> + DeviceRawAPI<TC> + DeviceRawAPI<MaybeUninit<TC>>,
10{
11    /// Element-wise assignment in col-major order, without no promise that
12    /// input layouts are broadcastable.
13    fn assign_arbitary(
14        &self,
15        c: &mut <Self as DeviceRawAPI<TC>>::Raw,
16        lc: &Layout<DC>,
17        a: &<Self as DeviceRawAPI<TA>>::Raw,
18        la: &Layout<DA>,
19    ) -> Result<()>;
20
21    fn assign_arbitary_uninit(
22        &self,
23        c: &mut <Self as DeviceRawAPI<MaybeUninit<TC>>>::Raw,
24        lc: &Layout<DC>,
25        a: &<Self as DeviceRawAPI<TA>>::Raw,
26        la: &Layout<DA>,
27    ) -> Result<()>;
28}
29
30pub trait OpAssignAPI<TC, D, TA = TC>
31where
32    D: DimAPI,
33    Self: DeviceRawAPI<TA> + DeviceRawAPI<TC> + DeviceRawAPI<MaybeUninit<TC>>,
34{
35    /// Element-wise assignment for same layout arrays.
36    fn assign(
37        &self,
38        c: &mut <Self as DeviceRawAPI<TC>>::Raw,
39        lc: &Layout<D>,
40        a: &<Self as DeviceRawAPI<TA>>::Raw,
41        la: &Layout<D>,
42    ) -> Result<()>;
43
44    fn assign_uninit(
45        &self,
46        c: &mut <Self as DeviceRawAPI<MaybeUninit<TC>>>::Raw,
47        lc: &Layout<D>,
48        a: &<Self as DeviceRawAPI<TA>>::Raw,
49        la: &Layout<D>,
50    ) -> Result<()>;
51
52    fn fill(&self, c: &mut <Self as DeviceRawAPI<TC>>::Raw, lc: &Layout<D>, fill: TA) -> Result<()>;
53}