poulpy/poulpy-hal/src/oep/scratch.rs
poulpy-hal/src/oep/scratch.rsRaw
1use crate::layouts::{Backend, MatZnx, ScalarZnx, Scratch, ScratchOwned, SvpPPol, VecZnx, VecZnxBig, VecZnxDft, VmpPMat};
2
3/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
4/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
5/// * See [crate::api::ScratchOwnedAlloc] for corresponding public API.
6/// # Safety [crate::doc::backend_safety] for safety contract.
7pub unsafe trait ScratchOwnedAllocImpl<B: Backend> {
8 fn scratch_owned_alloc_impl(size: usize) -> ScratchOwned<B>;
9}
10
11/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
12/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
13/// * See [crate::api::ScratchOwnedBorrow] for corresponding public API.
14/// # Safety [crate::doc::backend_safety] for safety contract.
15pub unsafe trait ScratchOwnedBorrowImpl<B: Backend> {
16 fn scratch_owned_borrow_impl(scratch: &mut ScratchOwned<B>) -> &mut Scratch<B>;
17}
18
19/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
20/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
21/// * See [crate::api::ScratchFromBytes] for corresponding public API.
22/// # Safety [crate::doc::backend_safety] for safety contract.
23pub unsafe trait ScratchFromBytesImpl<B: Backend> {
24 fn scratch_from_bytes_impl(data: &mut [u8]) -> &mut Scratch<B>;
25}
26
27/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
28/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
29/// * See [crate::api::ScratchAvailable] for corresponding public API.
30/// # Safety [crate::doc::backend_safety] for safety contract.
31pub unsafe trait ScratchAvailableImpl<B: Backend> {
32 fn scratch_available_impl(scratch: &Scratch<B>) -> usize;
33}
34
35/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
36/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
37/// * See [crate::api::ScratchOwnedAlloc] for corresponding public API.
38/// # Safety [crate::doc::backend_safety] for safety contract.
39pub unsafe trait TakeSliceImpl<B: Backend> {
40 fn take_slice_impl<T>(scratch: &mut Scratch<B>, len: usize) -> (&mut [T], &mut Scratch<B>);
41}
42
43/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
44/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
45/// * See [crate::api::TakeScalarZnx] for corresponding public API.
46/// # Safety [crate::doc::backend_safety] for safety contract.
47pub unsafe trait TakeScalarZnxImpl<B: Backend> {
48 fn take_scalar_znx_impl(scratch: &mut Scratch<B>, n: usize, cols: usize) -> (ScalarZnx<&mut [u8]>, &mut Scratch<B>);
49}
50
51/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
52/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
53/// * See [crate::api::TakeSvpPPol] for corresponding public API.
54/// # Safety [crate::doc::backend_safety] for safety contract.
55pub unsafe trait TakeSvpPPolImpl<B: Backend> {
56 fn take_svp_ppol_impl(scratch: &mut Scratch<B>, n: usize, cols: usize) -> (SvpPPol<&mut [u8], B>, &mut Scratch<B>);
57}
58
59/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
60/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
61/// * See [crate::api::TakeVecZnx] for corresponding public API.
62/// # Safety [crate::doc::backend_safety] for safety contract.
63pub unsafe trait TakeVecZnxImpl<B: Backend> {
64 fn take_vec_znx_impl(scratch: &mut Scratch<B>, n: usize, cols: usize, size: usize) -> (VecZnx<&mut [u8]>, &mut Scratch<B>);
65}
66
67/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
68/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
69/// * See [crate::api::TakeVecZnxSlice] for corresponding public API.
70/// # Safety [crate::doc::backend_safety] for safety contract.
71pub unsafe trait TakeVecZnxSliceImpl<B: Backend> {
72 fn take_vec_znx_slice_impl(
73 scratch: &mut Scratch<B>,
74 len: usize,
75 n: usize,
76 cols: usize,
77 size: usize,
78 ) -> (Vec<VecZnx<&mut [u8]>>, &mut Scratch<B>);
79}
80
81/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
82/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
83/// * See [crate::api::TakeVecZnxBig] for corresponding public API.
84/// # Safety [crate::doc::backend_safety] for safety contract.
85pub unsafe trait TakeVecZnxBigImpl<B: Backend> {
86 fn take_vec_znx_big_impl(
87 scratch: &mut Scratch<B>,
88 n: usize,
89 cols: usize,
90 size: usize,
91 ) -> (VecZnxBig<&mut [u8], B>, &mut Scratch<B>);
92}
93
94/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
95/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
96/// * See [crate::api::TakeVecZnxDft] for corresponding public API.
97/// # Safety [crate::doc::backend_safety] for safety contract.
98pub unsafe trait TakeVecZnxDftImpl<B: Backend> {
99 fn take_vec_znx_dft_impl(
100 scratch: &mut Scratch<B>,
101 n: usize,
102 cols: usize,
103 size: usize,
104 ) -> (VecZnxDft<&mut [u8], B>, &mut Scratch<B>);
105}
106
107/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
108/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
109/// * See [crate::api::TakeVecZnxDftSlice] for corresponding public API.
110/// # Safety [crate::doc::backend_safety] for safety contract.
111pub unsafe trait TakeVecZnxDftSliceImpl<B: Backend> {
112 fn take_vec_znx_dft_slice_impl(
113 scratch: &mut Scratch<B>,
114 len: usize,
115 n: usize,
116 cols: usize,
117 size: usize,
118 ) -> (Vec<VecZnxDft<&mut [u8], B>>, &mut Scratch<B>);
119}
120
121/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
122/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
123/// * See [crate::api::TakeVmpPMat] for corresponding public API.
124/// # Safety [crate::doc::backend_safety] for safety contract.
125pub unsafe trait TakeVmpPMatImpl<B: Backend> {
126 fn take_vmp_pmat_impl(
127 scratch: &mut Scratch<B>,
128 n: usize,
129 rows: usize,
130 cols_in: usize,
131 cols_out: usize,
132 size: usize,
133 ) -> (VmpPMat<&mut [u8], B>, &mut Scratch<B>);
134}
135
136/// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe)
137/// * See the [poulpy-backend/src/cpu_fft64_ref/scratch.rs](https://github.com/phantomzone-org/poulpy/blob/main/poulpy-backend/src/cpu_fft64_ref/scratch.rs) reference implementation.
138/// * See [crate::api::TakeMatZnx] for corresponding public API.
139/// # Safety [crate::doc::backend_safety] for safety contract.
140pub unsafe trait TakeMatZnxImpl<B: Backend> {
141 fn take_mat_znx_impl(
142 scratch: &mut Scratch<B>,
143 n: usize,
144 rows: usize,
145 cols_in: usize,
146 cols_out: usize,
147 size: usize,
148 ) -> (MatZnx<&mut [u8]>, &mut Scratch<B>);
149}