Skip to main content

BackendBuffer

Trait BackendBuffer 

Source
pub trait BackendBuffer<T>:
    Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn backend_family(&self) -> &'static str;
    fn len(&self) -> usize;
    fn as_any(&self) -> &dyn Any;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Opaque backend-owned tensor buffer.

Tensor core never inspects backend-native allocations directly. Backend crates store their own concrete handle types behind this trait and downcast inside the owning backend only.

§Examples

use std::sync::Arc;
use tenferro_tensor::{BackendBuffer, BufferHandle};

let buffer: Arc<dyn BackendBuffer<f64>> = Arc::new(BufferHandle::<f64>::new_with_len(7, 2));
assert_eq!(buffer.backend_family(), "opaque");
assert_eq!(buffer.len(), 2);

Required Methods§

Source

fn backend_family(&self) -> &'static str

Stable backend family identifier.

Source

fn len(&self) -> usize

Number of logical elements in the backend allocation.

Source

fn as_any(&self) -> &dyn Any

Type-erased access for the backend crate that owns the concrete handle.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true when the backend allocation is empty.

Implementors§

Source§

impl<T: Send + Sync + 'static> BackendBuffer<T> for BufferHandle<T>