From 7adc8c903a2963fd35a8a2d2e353ed086387396c Mon Sep 17 00:00:00 2001 From: Laurent Mazare Date: Thu, 13 Jul 2023 13:52:36 +0100 Subject: [PATCH] Expose the storage publicly. (#157) --- candle-core/src/tensor.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/candle-core/src/tensor.rs b/candle-core/src/tensor.rs index 4aa2ff91..ffd190ca 100644 --- a/candle-core/src/tensor.rs +++ b/candle-core/src/tensor.rs @@ -1531,6 +1531,12 @@ impl Tensor { fn storage(&self) -> std::sync::RwLockReadGuard<'_, Storage> { self.storage.read().unwrap() } + + /// The storage used by this tensor, together with the layout to use to access it safely. + pub fn storage_and_layout(&self) -> (std::sync::RwLockReadGuard<'_, Storage>, &Layout) { + let storage = self.storage.read().unwrap(); + (storage, &self.layout) + } } macro_rules! bin_trait {