TensorComplexScalePrims

Trait TensorComplexScalePrims 

Source
pub trait TensorComplexScalePrims<Input: ComplexFloat + Scalar>
where Input::Real: Scalar + Send + Sync,
{ type Plan; type Context; // Required methods fn plan( ctx: &mut Self::Context, desc: &ComplexScalePrimsDescriptor, shapes: &[&[usize]], ) -> Result<Self::Plan>; 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<()>; fn has_complex_scale_support(desc: ComplexScalePrimsDescriptor) -> bool; }
Expand description

Cross-dtype complex-by-real pointwise family.

The left-hand side and output are complex-valued, while the right-hand side is real-valued. The execution contract matches the rest of tenferro prims: output <- alpha * (lhs * rhs) + beta * output.

§Examples

use num_complex::Complex64;
use tenferro_prims::{
    ComplexScalePrimsDescriptor, CpuBackend, CpuContext, TensorComplexScalePrims,
};

let mut ctx = CpuContext::new(1);
let desc = ComplexScalePrimsDescriptor::PointwiseMul;
let _plan = <CpuBackend as TensorComplexScalePrims<Complex64>>::plan(
    &mut ctx,
    &desc,
    &[&[2, 2], &[2, 2], &[2, 2]],
)
.unwrap();

Required Associated Types§

Source

type Plan

Backend plan type.

Source

type Context

Backend execution context.

Required Methods§

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Input> TensorComplexScalePrims<Input> for CpuBackend
where Input: ComplexFloat + Scalar + 'static + Add<Output = Input> + Mul<Input::Real, Output = Input> + Mul<Output = Input>, Input::Real: Scalar + Send + Sync,

Source§

type Plan = CpuComplexScalePlan

Source§

type Context = CpuContext

Source§

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

Available on non-crate feature cuda only.
Source§

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