Skip to main content

tenferro_gpu/cuda/
capability.rs

1//! The public CUDA capability-table surface.
2//!
3//! The table itself lives in [`crate::capability`] so it compiles without the `cuda` feature
4//! and its guide table can be checked in a default-features build (issue #2477). This module
5//! is the engine-facing spelling: the `TensorBackendCapability` impl for [`CudaEngine`] and
6//! the public re-export.
7
8use tenferro_tensor::{BackendId, OperationCapability, TensorBackendCapability};
9
10use super::CudaEngine;
11
12/// Return the CUDA backend operation capability descriptor table.
13///
14/// The table states what this backend serves natively; it is written down rather than derived
15/// from the kernel catalogue's `accepts` list, and `tests/seam_capability.rs` holds each entry to
16/// the engine's observed behaviour. `docs/guides/devices-and-gpu.md` renders the same table and
17/// a default-features test checks the two agree.
18///
19/// # Examples
20///
21/// ```rust
22/// use tenferro_core_ops::PrimitiveOpKind;
23/// use tenferro_gpu::cuda::cuda_capabilities;
24/// use tenferro_tensor::{DType, SupportLevel};
25///
26/// let add = cuda_capabilities()
27///     .iter()
28///     .find(|entry| entry.op == PrimitiveOpKind::Add && entry.dtype == DType::I32)
29///     .unwrap();
30/// assert_eq!(add.result, SupportLevel::Native);
31/// ```
32#[must_use]
33pub const fn cuda_capabilities() -> &'static [OperationCapability] {
34    crate::capability::cuda_capability_table()
35}
36
37impl TensorBackendCapability for CudaEngine {
38    fn backend_id(&self) -> BackendId {
39        BackendId::Cuda
40    }
41
42    fn capabilities(&self) -> &'static [OperationCapability] {
43        crate::capability::cuda_capability_table()
44    }
45}