mirror of
https://github.com/huggingface/candle.git
synced 2025-06-17 02:58:50 +00:00
Split the tensor file.
This commit is contained in:
18
src/device.rs
Normal file
18
src/device.rs
Normal 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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user