Add Hardware Abstraction Layer (#56)

This commit is contained in:
Jean-Philippe Bossuat
2025-08-08 19:22:42 +02:00
committed by GitHub
parent 833520b163
commit 0e0745065e
194 changed files with 17397 additions and 11955 deletions

View File

@@ -0,0 +1,41 @@
use crate::{
hal::{
layouts::{Backend, MatZnxOwned, Module},
oep::{MatZnxAllocBytesImpl, MatZnxAllocImpl, MatZnxFromBytesImpl},
},
implementation::cpu_spqlios::CPUAVX,
};
unsafe impl<B: Backend> MatZnxAllocImpl<B> for B
where
B: CPUAVX,
{
fn mat_znx_alloc_impl(module: &Module<B>, rows: usize, cols_in: usize, cols_out: usize, size: usize) -> MatZnxOwned {
MatZnxOwned::new(module.n(), rows, cols_in, cols_out, size)
}
}
unsafe impl<B: Backend> MatZnxAllocBytesImpl<B> for B
where
B: CPUAVX,
{
fn mat_znx_alloc_bytes_impl(module: &Module<B>, rows: usize, cols_in: usize, cols_out: usize, size: usize) -> usize {
MatZnxOwned::bytes_of(module.n(), rows, cols_in, cols_out, size)
}
}
unsafe impl<B: Backend> MatZnxFromBytesImpl<B> for B
where
B: CPUAVX,
{
fn mat_znx_from_bytes_impl(
module: &Module<B>,
rows: usize,
cols_in: usize,
cols_out: usize,
size: usize,
bytes: Vec<u8>,
) -> MatZnxOwned {
MatZnxOwned::new_from_bytes(module.n(), rows, cols_in, cols_out, size, bytes)
}
}