mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 21:26:41 +01:00
Ref. + AVX code & generic tests + benches (#85)
This commit is contained in:
committed by
GitHub
parent
99b9e3e10e
commit
56dbd29c59
@@ -1,15 +1,21 @@
|
||||
use std::marker::PhantomData;
|
||||
use std::{
|
||||
hash::{DefaultHasher, Hasher},
|
||||
marker::PhantomData,
|
||||
};
|
||||
|
||||
use rand_distr::num_traits::Zero;
|
||||
use std::fmt;
|
||||
|
||||
use crate::{
|
||||
alloc_aligned,
|
||||
layouts::{Backend, Data, DataMut, DataRef, DataView, DataViewMut, ZnxInfos, ZnxSliceSize, ZnxView, ZnxViewMut, ZnxZero},
|
||||
layouts::{
|
||||
Backend, Data, DataMut, DataRef, DataView, DataViewMut, DigestU64, ZnxInfos, ZnxSliceSize, ZnxView, ZnxViewMut, ZnxZero,
|
||||
},
|
||||
oep::VecZnxBigAllocBytesImpl,
|
||||
};
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
#[derive(PartialEq, Eq, Hash)]
|
||||
pub struct VecZnxBig<D: Data, B: Backend> {
|
||||
pub data: D,
|
||||
pub n: usize,
|
||||
@@ -19,6 +25,18 @@ pub struct VecZnxBig<D: Data, B: Backend> {
|
||||
pub _phantom: PhantomData<B>,
|
||||
}
|
||||
|
||||
impl<D: DataRef, B: Backend> DigestU64 for VecZnxBig<D, B> {
|
||||
fn digest_u64(&self) -> u64 {
|
||||
let mut h: DefaultHasher = DefaultHasher::new();
|
||||
h.write(self.data.as_ref());
|
||||
h.write_usize(self.n);
|
||||
h.write_usize(self.cols);
|
||||
h.write_usize(self.size);
|
||||
h.write_usize(self.max_size);
|
||||
h.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: Data, B: Backend> ZnxSliceSize for VecZnxBig<D, B> {
|
||||
fn sl(&self) -> usize {
|
||||
B::layout_big_word_count() * self.n() * self.cols()
|
||||
|
||||
Reference in New Issue
Block a user