pub enum Buffer<T> {
Host(Vec<T>),
Backend(Arc<dyn BackendBuffer<T>>),
}Expand description
Variants§
Host(Vec<T>)
Backend(Arc<dyn BackendBuffer<T>>)
Implementations§
Source§impl<T: 'static> Buffer<T>
impl<T: 'static> Buffer<T>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the physical element count in this buffer.
§Examples
use tenferro_tensor::Buffer;
assert_eq!(Buffer::Host(vec![1_i32, 2]).len(), 2);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return whether this buffer has no physical elements.
§Examples
use tenferro_tensor::Buffer;
assert!(Buffer::<i32>::Host(Vec::new()).is_empty());Sourcepub fn is_backend(&self) -> bool
pub fn is_backend(&self) -> bool
Return whether the storage is backend-owned rather than host-owned.
§Examples
use tenferro_tensor::Buffer;
assert!(!Buffer::Host(vec![1_i32]).is_backend());Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Buffer<T>
impl<T> !RefUnwindSafe for Buffer<T>
impl<T> Send for Buffer<T>where
T: Send,
impl<T> Sync for Buffer<T>where
T: Sync,
impl<T> Unpin for Buffer<T>where
T: Unpin,
impl<T> UnsafeUnpin for Buffer<T>
impl<T> !UnwindSafe for Buffer<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more