mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 21:26:41 +01:00
Add Hardware Abstraction Layer (#56)
This commit is contained in:
committed by
GitHub
parent
833520b163
commit
0e0745065e
41
backend/src/implementation/cpu_spqlios/mat_znx.rs
Normal file
41
backend/src/implementation/cpu_spqlios/mat_znx.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user