Split the tensor file.

This commit is contained in:
laurent
2023-06-19 17:34:13 +01:00
parent 9698211d56
commit 844704de5c
5 changed files with 48 additions and 32 deletions

18
src/device.rs Normal file
View File

@ -0,0 +1,18 @@
use crate::{DType, Storage};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Device {
Cpu,
}
impl Device {
pub(crate) fn zeros(&self, shape: &[usize], dtype: DType) -> Storage {
match self {
Device::Cpu => {
let elem_count: usize = shape.iter().product();
let buffer = vec![0; elem_count * dtype.size_in_bytes()];
Storage::Cpu { dtype, buffer }
}
}
}
}