summaryrefslogtreecommitdiff
path: root/candle-core/src/cpu_backend/mod.rs
diff options
context:
space:
mode:
authorLaurent Mazare <laurent.mazare@gmail.com>2024-04-23 13:23:27 +0200
committerGitHub <noreply@github.com>2024-04-23 13:23:27 +0200
commit8a05743a21768405217576a1b9557936be74ed90 (patch)
tree8c6eab8ca1f5496d02b874e7d0a340ee70afe9c5 /candle-core/src/cpu_backend/mod.rs
parentb2e816752bb3b81ed5daaf4b623c3b5e6c0f7b67 (diff)
downloadcandle-8a05743a21768405217576a1b9557936be74ed90.tar.gz
candle-8a05743a21768405217576a1b9557936be74ed90.tar.bz2
candle-8a05743a21768405217576a1b9557936be74ed90.zip
Add StorageRef. (#2113)
* Add the storage-ref bits. * Add the metal implementation.
Diffstat (limited to 'candle-core/src/cpu_backend/mod.rs')
-rw-r--r--candle-core/src/cpu_backend/mod.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/candle-core/src/cpu_backend/mod.rs b/candle-core/src/cpu_backend/mod.rs
index c8cf7e1e..299b1e6e 100644
--- a/candle-core/src/cpu_backend/mod.rs
+++ b/candle-core/src/cpu_backend/mod.rs
@@ -27,6 +27,17 @@ pub enum CpuStorage {
}
#[derive(Debug, Clone)]
+pub enum CpuStorageRef<'a> {
+ U8(&'a [u8]),
+ U32(&'a [u32]),
+ I64(&'a [i64]),
+ BF16(&'a [bf16]),
+ F16(&'a [f16]),
+ F32(&'a [f32]),
+ F64(&'a [f64]),
+}
+
+#[derive(Debug, Clone)]
pub struct CpuDevice;
struct Cmp(CmpOp);
@@ -2445,6 +2456,10 @@ impl BackendDevice for CpuDevice {
true
}
+ fn storage_from_slice<T: crate::WithDType>(&self, s: &[T]) -> Result<Self::Storage> {
+ Ok(T::to_cpu_storage(s))
+ }
+
fn storage_from_cpu_storage(&self, s: &CpuStorage) -> Result<Self::Storage> {
Ok(s.clone())
}