RocmBackend

Struct RocmBackend 

Source
pub struct RocmBackend { /* private fields */ }
Expand description

ROCm backend using hipTENSOR via runtime dlopen.

Status: Not yet implemented. All methods currently return errors. The type exists to define the intended API surface. plan() and execute() return Err(DeviceError). load_hiptensor() on crate::BackendRegistry also returns an error.

When implemented, will be loaded at runtime from a user-provided .so path with no compile-time ROCm SDK dependency. Will implement the semiring-family traits for standard arithmetic on AMD GPUs.

hipTENSOR natively supports contraction, reduction, and elementwise building blocks. Structural permute stays a tensor view, and any required materialization path is modeled through MakeContiguous. AntiTrace and AntiDiag will be composed via Contract(eye, dC).

§Examples

// Aspirational API — not yet functional.
use tenferro_prims::{RocmBackend, BackendRegistry};

let mut registry = BackendRegistry::new();
registry.load_hiptensor("/usr/lib/libhiptensor.so").unwrap();

Implementations§

Source§

impl RocmBackend

Source

pub fn resolve_conj<T: Scalar + Conjugate>( _ctx: &mut RocmContext, src: &Tensor<T>, ) -> Tensor<T>

Materialize a lazily-conjugated tensor on GPU.

Status: Stub fallback. If data is CPU-accessible, this materializes conjugation into a new non-conjugated tensor. Otherwise it returns a clone of src.

When implemented, will use the analytic/scalar family execution traits to produce a new tensor with conjugated = false.

Trait Implementations§

Source§

impl Drop for RocmBackend

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<S: Scalar> TensorAnalyticPrims<Standard<S>> for RocmBackend

Source§

type Plan = ()

Source§

type Context = RocmContext

Source§

fn plan( _ctx: &mut Self::Context, desc: &AnalyticPrimsDescriptor, _shapes: &[&[usize]], ) -> Result<Self::Plan>

Plan an analytic-family operation for the given input/output shapes. Read more
Source§

fn execute( _ctx: &mut Self::Context, _plan: &Self::Plan, _alpha: S, _inputs: &[&Tensor<S>], _beta: S, _output: &mut Tensor<S>, ) -> Result<()>

Execute a previously planned analytic-family operation. Read more
Source§

fn has_analytic_support(_desc: AnalyticPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor. Read more
Source§

impl<Input> TensorComplexRealPrims<Input> for RocmBackend
where Input: ComplexFloat + Scalar, Input::Real: Scalar,

Source§

type Real = <Input as ComplexFloat>::Real

The real-valued output scalar type.
Source§

type Plan = ()

Backend plan type.
Source§

type Context = RocmContext

Backend execution context.
Source§

fn plan( _ctx: &mut Self::Context, desc: &ComplexRealPrimsDescriptor, _shapes: &[&[usize]], ) -> Result<Self::Plan>

Plan a complex-to-real unary operation for the given input/output shapes.
Source§

fn execute( _ctx: &mut Self::Context, _plan: &Self::Plan, _alpha: Input::Real, _inputs: &[&Tensor<Input>], _beta: Input::Real, _output: &mut Tensor<Self::Real>, ) -> Result<()>

Execute a previously planned complex-to-real unary operation. Read more
Source§

fn has_complex_real_support(_desc: ComplexRealPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.
Source§

impl<Input> TensorComplexScalePrims<Input> for RocmBackend
where Input: ComplexFloat + Scalar, Input::Real: Scalar + Send + Sync,

Source§

type Plan = ()

Backend plan type.
Source§

type Context = RocmContext

Backend execution context.
Source§

fn plan( _ctx: &mut Self::Context, desc: &ComplexScalePrimsDescriptor, _shapes: &[&[usize]], ) -> Result<Self::Plan>

Plan a complex-by-real pointwise operation for the given shapes.
Source§

fn execute( _ctx: &mut Self::Context, _plan: &Self::Plan, _alpha: Input, _lhs: &Tensor<Input>, _rhs: &Tensor<Input::Real>, _beta: Input, _output: &mut Tensor<Input>, ) -> Result<()>

Execute a previously planned complex-by-real pointwise operation.
Source§

fn has_complex_scale_support(_desc: ComplexScalePrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.
Source§

impl<S: Scalar> TensorIndexingPrims<Standard<S>> for RocmBackend

Source§

type Plan = ()

Backend-specific execution plan.
Source§

type Context = RocmContext

Backend execution context.
Source§

fn plan( _ctx: &mut Self::Context, desc: &IndexingPrimsDescriptor, _shapes: &[&[usize]], ) -> Result<Self::Plan>

Plan an indexing operation for the given input/index/output shapes. Read more
Source§

fn execute( _ctx: &mut Self::Context, _plan: &Self::Plan, _inputs: &[&Tensor<S>], _indices: &Tensor<i64>, _output: &mut Tensor<S>, ) -> Result<()>

Execute a previously planned indexing operation. Read more
Source§

fn has_indexing_support(_desc: IndexingPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.
Source§

impl<S: Scalar + NumCast> TensorMetadataCastPrims<S> for RocmBackend

Source§

type Plan = MetadataCastPrimsDescriptor

Backend plan type.
Source§

type Context = RocmContext

Backend execution context.
Source§

fn plan( _ctx: &mut RocmContext, desc: &MetadataCastPrimsDescriptor, _shapes: &[&[usize]], ) -> Result<Self::Plan>

Plan a metadata-to-scalar bridge operation.
Source§

fn execute( _ctx: &mut RocmContext, _plan: &Self::Plan, _alpha: S, _inputs: &[MetadataScalarTensorRef<'_, S>], _beta: S, _output: &mut Tensor<S>, ) -> Result<()>

Execute a previously planned metadata-to-scalar bridge operation. Read more
Source§

fn has_metadata_cast_support(_desc: MetadataCastPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.
Source§

impl TensorMetadataPrims for RocmBackend

Source§

type Plan = MetadataPrimsDescriptor

Backend plan type.
Source§

type Context = RocmContext

Backend execution context.
Source§

fn plan( _ctx: &mut RocmContext, desc: &MetadataPrimsDescriptor, _inputs: &[MetadataTensorRef<'_>], _output: MetadataTensorMut<'_>, ) -> Result<Self::Plan>

Plan a metadata-family operation for the given input and output tensor handles.
Source§

fn execute( _ctx: &mut RocmContext, _plan: &Self::Plan, _inputs: &[MetadataTensorRef<'_>], _output: MetadataTensorMut<'_>, ) -> Result<()>

Execute a previously planned metadata-family operation in overwrite mode.
Source§

fn has_metadata_support(_desc: MetadataPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.
Source§

impl TensorRngPrims<Standard<f64>> for RocmBackend

Source§

type Plan = (RngPrimsDescriptor, Vec<usize>)

Backend-specific execution plan.
Source§

type Context = RocmContext

Backend execution context.
Source§

fn plan( _ctx: &mut Self::Context, desc: &RngPrimsDescriptor, _shapes: &[&[usize]], ) -> Result<Self::Plan>

Plan a tensor RNG operation for the given output shape.
Source§

fn execute( _ctx: &mut Self::Context, _plan: &Self::Plan, _generator: &mut Generator, _output: &mut Tensor<f64>, ) -> Result<()>

Execute a previously planned RNG operation.
Source§

fn has_rng_support(_desc: RngPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.
Source§

impl TensorRngPrims<Standard<i32>> for RocmBackend

Source§

type Plan = (RngPrimsDescriptor, Vec<usize>)

Backend-specific execution plan.
Source§

type Context = RocmContext

Backend execution context.
Source§

fn plan( _ctx: &mut Self::Context, desc: &RngPrimsDescriptor, _shapes: &[&[usize]], ) -> Result<Self::Plan>

Plan a tensor RNG operation for the given output shape.
Source§

fn execute( _ctx: &mut Self::Context, _plan: &Self::Plan, _generator: &mut Generator, _output: &mut Tensor<i32>, ) -> Result<()>

Execute a previously planned RNG operation.
Source§

fn has_rng_support(_desc: RngPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.
Source§

impl<S: Scalar> TensorScalarPrims<Standard<S>> for RocmBackend

Source§

type Plan = ()

Source§

type Context = RocmContext

Source§

fn plan( _ctx: &mut Self::Context, desc: &ScalarPrimsDescriptor, _shapes: &[&[usize]], ) -> Result<Self::Plan>

Plan a scalar-family operation for the given input/output shapes. Read more
Source§

fn execute( _ctx: &mut Self::Context, _plan: &Self::Plan, _alpha: S, _inputs: &[&Tensor<S>], _beta: S, _output: &mut Tensor<S>, ) -> Result<()>

Execute a previously planned scalar-family operation. Read more
Source§

fn has_scalar_support(_desc: ScalarPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor. Read more
Source§

impl<S: Scalar> TensorSemiringCore<Standard<S>> for RocmBackend

Source§

type Plan = RocmPlan<S>

Backend-specific plan type.
Source§

type Context = RocmContext

Backend-specific execution context.
Source§

fn plan( _ctx: &mut RocmContext, _desc: &SemiringCoreDescriptor, _shapes: &[&[usize]], ) -> Result<RocmPlan<S>>

Plan a semiring-core operation.
Source§

fn execute( _ctx: &mut RocmContext, _plan: &RocmPlan<S>, _alpha: S, _inputs: &[&Tensor<S>], _beta: S, _output: &mut Tensor<S>, ) -> Result<()>

Execute a semiring-core operation.
Source§

impl<S: Scalar> TensorSemiringFastPath<Standard<S>> for RocmBackend

Source§

type Plan = RocmPlan<S>

Backend-specific plan type.
Source§

type Context = RocmContext

Backend-specific execution context.
Source§

fn plan( _ctx: &mut RocmContext, _desc: &SemiringFastPathDescriptor, _shapes: &[&[usize]], ) -> Result<RocmPlan<S>>

Plan an optional semiring fast path.
Source§

fn execute( _ctx: &mut RocmContext, _plan: &RocmPlan<S>, _alpha: S, _inputs: &[&Tensor<S>], _beta: S, _output: &mut Tensor<S>, ) -> Result<()>

Execute an optional semiring fast path.
Source§

fn has_fast_path(_desc: SemiringFastPathDescriptor) -> bool

Query whether the optional path is available.
Source§

impl<S: Scalar + PartialOrd> TensorSortPrims<Standard<S>> for RocmBackend

Source§

type Plan = ()

Backend-specific execution plan.
Source§

type Context = RocmContext

Backend execution context.
Source§

fn plan( _ctx: &mut Self::Context, desc: &SortPrimsDescriptor, _shapes: &[&[usize]], ) -> Result<Self::Plan>

Plan a sort operation for the given input shape. Read more
Source§

fn execute( _ctx: &mut Self::Context, _plan: &Self::Plan, _input: &Tensor<S>, _values_out: &mut Tensor<S>, _indices_out: &mut Tensor<i64>, ) -> Result<()>

Execute a previously planned sort operation. Read more
Source§

fn has_sort_support(_desc: &SortPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.
Source§

impl Send for RocmBackend

§Safety

RocmBackend can be safely sent across threads because:

  • The _handle is an opaque pointer to a hipTENSOR handle
  • The _lib (libloading::Library) is thread-safe after loading
  • The handle is read-only after construction
  • Drop clears the handle before the library is unloaded, preventing use-after-free
Source§

impl Sync for RocmBackend

§Safety

RocmBackend can be safely shared across threads because:

  • The hipTENSOR handle is designed for concurrent use from multiple threads
  • The library handle (_lib) is read-only after construction
  • Symbol lookup via dlsym is thread-safe on POSIX systems
  • Drop uses &mut self, ensuring exclusive access during cleanup

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

impl<T> MaybeSend for T

§

impl<T> MaybeSendSync for T

§

impl<T> MaybeSync for T