Skip to main content

BackendSession

Trait BackendSession 

Source
pub trait BackendSession: TensorBackendOps + SessionCachedDot { }
Expand description

Execution session surface for dense tensor backends.

All operations run within a backend-owned execution scope such as a CPU thread policy or a GPU stream. Individual ops must not try to re-enter that scope.

§Examples

use tenferro_tensor::{BackendSessionHost, Tensor, TypedTensor};

fn add_in_session<B: BackendSessionHost>(
    backend: &mut B,
    a: &Tensor,
    b: &Tensor,
) -> tenferro_tensor::Result<Tensor>
where
    B: tenferro_tensor::TensorBackend,
{
    backend.with_backend_session(|exec| exec.add(a, b))
}

Implementors§

Source§

impl<T> BackendSession for T
where T: TensorBackendOps + SessionCachedDot + ?Sized,