poulpy/backend/src/implementation/cpu_spqlios/scalar_znx.rs
backend/src/implementation/cpu_spqlios/scalar_znx.rsRaw
1use crate::{
2 hal::{
3 layouts::{Backend, ScalarZnxOwned},
4 oep::{ScalarZnxAllocBytesImpl, ScalarZnxAllocImpl, ScalarZnxFromBytesImpl},
5 },
6 implementation::cpu_spqlios::CPUAVX,
7};
8
9unsafe impl<B: Backend> ScalarZnxAllocBytesImpl<B> for B
10where
11 B: CPUAVX,
12{
13 fn scalar_znx_alloc_bytes_impl(n: usize, cols: usize) -> usize {
14 ScalarZnxOwned::bytes_of(n, cols)
15 }
16}
17
18unsafe impl<B: Backend> ScalarZnxAllocImpl<B> for B
19where
20 B: CPUAVX,
21{
22 fn scalar_znx_alloc_impl(n: usize, cols: usize) -> ScalarZnxOwned {
23 ScalarZnxOwned::alloc(n, cols)
24 }
25}
26
27unsafe impl<B: Backend> ScalarZnxFromBytesImpl<B> for B
28where
29 B: CPUAVX,
30{
31 fn scalar_znx_from_bytes_impl(n: usize, cols: usize, bytes: Vec<u8>) -> ScalarZnxOwned {
32 ScalarZnxOwned::from_bytes(n, cols, bytes)
33 }
34}