Expose the storage publicly. (#157)

This commit is contained in:
Laurent Mazare
2023-07-13 13:52:36 +01:00
committed by GitHub
parent 21aa29ddce
commit 7adc8c903a

View File

@ -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 {