pub struct Session<'s> { /* private fields */ }Expand description
Public CubeCL extension session.
Not constructible by users; obtained only from
CudaExecSession::with_cubecl.
The session borrows the exact tenferro CubeCL client for the request scope
and is !Send + !Sync by construction, so the execution authority cannot
migrate to another thread.
Implementations§
Source§impl<'s> Session<'s>
impl<'s> Session<'s>
Sourcepub fn tensor_binding<T>(
&self,
tensor: &TypedTensor<T, impl TensorRank>,
op: &'static str,
) -> Result<TensorBinding<CubeclCudaRuntime>>where
T: CubeElement + TensorScalar + Clone,
pub fn tensor_binding<T>(
&self,
tensor: &TypedTensor<T, impl TensorRank>,
op: &'static str,
) -> Result<TensorBinding<CubeclCudaRuntime>>where
T: CubeElement + TensorScalar + Clone,
Build a CubeCL tensor binding for a GPU-backed tensor.
§Errors
Returns crate::Error::RuntimeState when the tensor is not resident
on this session’s runtime/device, or crate::Error::Validation when
its layout cannot be bound.
Sourcepub fn array_arg<T>(
&self,
tensor: &TypedTensor<T, impl TensorRank>,
op: &'static str,
) -> Result<ArrayArg<CubeclCudaRuntime>>where
T: CubeElement + TensorScalar + Clone,
pub fn array_arg<T>(
&self,
tensor: &TypedTensor<T, impl TensorRank>,
op: &'static str,
) -> Result<ArrayArg<CubeclCudaRuntime>>where
T: CubeElement + TensorScalar + Clone,
Build a CubeCL array argument for a GPU-backed tensor.
§Errors
Returns crate::Error::RuntimeState when the tensor is not resident
on this session’s runtime/device, or crate::Error::Validation when
its layout cannot be bound.
Sourcepub fn alloc_output<T>(&self, shape: &[usize]) -> Result<TypedTensor<T>>
pub fn alloc_output<T>(&self, shape: &[usize]) -> Result<TypedTensor<T>>
Allocate a dense GPU tensor on the session’s device.
§Errors
Returns crate::Error::Validation when the shape product overflows,
or crate::Error::BackendSource when allocation fails.
Sourcepub fn alloc_zero_output<T>(&self, shape: &[usize]) -> Result<TypedTensor<T>>
pub fn alloc_zero_output<T>(&self, shape: &[usize]) -> Result<TypedTensor<T>>
Allocate a dense GPU tensor zero-filled with the session’s device.
Reuses the backend’s fill-zero structural kernel; it never uploads a host tensor or exposes a device pointer to the caller.
§Errors
Returns crate::Error::Validation when the shape product, output
byte length, or launch count overflows, crate::Error::RuntimeState
when the output is not resident, or crate::Error::BackendSource
when allocation or backend resource inspection fails.
§Examples
use tenferro_gpu::cuda::cubecl::Session;
fn check(session: &Session<'_>) -> tenferro_tensor::Result<()> {
let _ = session.alloc_zero_output::<f32>(&[4])?;
Ok(())
}Sourcepub fn scale_tensor_write(
&self,
output: TensorWrite<'_>,
factor: f64,
) -> Result<()>
pub fn scale_tensor_write( &self, output: TensorWrite<'_>, factor: f64, ) -> Result<()>
Scale a mutable CUDA tensor in place by a real factor.
Supports F32, F64, C32, and C64 payloads; the factor is interpreted as a real scalar for complex payloads. This is the op-family scale primitive used for normalization after a vendor transform; it never exposes a device pointer to the caller.
§Errors
Returns crate::Error::RuntimeState when the tensor is not resident
on this session’s runtime, a typed layout error for a non-zero-offset
discontinuous view, or the typed unsupported-dtype error for other
payloads.
Sourcepub fn cube_count_1d(&self, len: usize) -> Result<CubeCount>
pub fn cube_count_1d(&self, len: usize) -> Result<CubeCount>
Return the cube count for a one-dimensional kernel domain of len.
§Errors
Returns crate::Error::Validation carrying
ValidationError::InvalidArgument when the one-dimensional launch for
len elements would require more than u32::MAX workgroups.
Sourcepub fn cube_dim_1d(&self) -> CubeDim
pub fn cube_dim_1d(&self) -> CubeDim
Return the standard one-dimensional CubeCL launch dimension.
Auto Trait Implementations§
impl<'s> !RefUnwindSafe for Session<'s>
impl<'s> !Send for Session<'s>
impl<'s> !Sync for Session<'s>
impl<'s> !UnwindSafe for Session<'s>
impl<'s> Freeze for Session<'s>
impl<'s> Unpin for Session<'s>
impl<'s> UnsafeUnpin for Session<'s>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more