poulpy_hal/api/
scratch.rs1use crate::layouts::{Backend, MatZnx, ScalarZnx, Scratch, SvpPPol, VecZnx, VecZnxBig, VecZnxDft, VmpPMat};
2
3pub trait ScratchOwnedAlloc<B: Backend> {
5 fn alloc(size: usize) -> Self;
6}
7
8pub trait ScratchOwnedBorrow<B: Backend> {
10 fn borrow(&mut self) -> &mut Scratch<B>;
11}
12
13pub trait ScratchFromBytes<B: Backend> {
15 fn from_bytes(data: &mut [u8]) -> &mut Scratch<B>;
16}
17
18pub trait ScratchAvailable {
20 fn available(&self) -> usize;
21}
22
23pub trait TakeSlice {
25 fn take_slice<T>(&mut self, len: usize) -> (&mut [T], &mut Self);
26}
27
28pub trait TakeScalarZnx {
31 fn take_scalar_znx(&mut self, n: usize, cols: usize) -> (ScalarZnx<&mut [u8]>, &mut Self);
32}
33
34pub trait TakeSvpPPol<B: Backend> {
37 fn take_svp_ppol(&mut self, n: usize, cols: usize) -> (SvpPPol<&mut [u8], B>, &mut Self);
38}
39
40pub trait TakeVecZnx {
43 fn take_vec_znx(&mut self, n: usize, cols: usize, size: usize) -> (VecZnx<&mut [u8]>, &mut Self);
44}
45
46pub trait TakeVecZnxSlice {
49 fn take_vec_znx_slice(&mut self, len: usize, n: usize, cols: usize, size: usize) -> (Vec<VecZnx<&mut [u8]>>, &mut Self);
50}
51
52pub trait TakeVecZnxBig<B: Backend> {
55 fn take_vec_znx_big(&mut self, n: usize, cols: usize, size: usize) -> (VecZnxBig<&mut [u8], B>, &mut Self);
56}
57
58pub trait TakeVecZnxDft<B: Backend> {
61 fn take_vec_znx_dft(&mut self, n: usize, cols: usize, size: usize) -> (VecZnxDft<&mut [u8], B>, &mut Self);
62}
63
64pub trait TakeVecZnxDftSlice<B: Backend> {
67 fn take_vec_znx_dft_slice(
68 &mut self,
69 len: usize,
70 n: usize,
71 cols: usize,
72 size: usize,
73 ) -> (Vec<VecZnxDft<&mut [u8], B>>, &mut Self);
74}
75
76pub trait TakeVmpPMat<B: Backend> {
79 fn take_vmp_pmat(
80 &mut self,
81 n: usize,
82 rows: usize,
83 cols_in: usize,
84 cols_out: usize,
85 size: usize,
86 ) -> (VmpPMat<&mut [u8], B>, &mut Self);
87}
88
89pub trait TakeMatZnx {
92 fn take_mat_znx(
93 &mut self,
94 n: usize,
95 rows: usize,
96 cols_in: usize,
97 cols_out: usize,
98 size: usize,
99 ) -> (MatZnx<&mut [u8]>, &mut Self);
100}
101
102pub trait TakeLike<'a, B: Backend, T> {
105 type Output;
106 fn take_like(&'a mut self, template: &T) -> (Self::Output, &'a mut Self);
107}