summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Mazare <laurent.mazare@gmail.com>2023-07-13 13:52:36 +0100
committerGitHub <noreply@github.com>2023-07-13 13:52:36 +0100
commit7adc8c903a2963fd35a8a2d2e353ed086387396c (patch)
tree194468437c5afcf4c9cf462ce207bd638dcdfb64
parent21aa29ddce4cf08dd534e2246b8d932a9c6570bc (diff)
downloadcandle-7adc8c903a2963fd35a8a2d2e353ed086387396c.tar.gz
candle-7adc8c903a2963fd35a8a2d2e353ed086387396c.tar.bz2
candle-7adc8c903a2963fd35a8a2d2e353ed086387396c.zip
Expose the storage publicly. (#157)
-rw-r--r--candle-core/src/tensor.rs6
1 files changed, 6 insertions, 0 deletions
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 {