pub trait TensorComplexRealPrims<Input: ComplexFloat + Scalar> {
type Real: Scalar + Send + Sync;
type Plan;
type Context;
// Required methods
fn plan(
ctx: &mut Self::Context,
desc: &ComplexRealPrimsDescriptor,
shapes: &[&[usize]],
) -> Result<Self::Plan>;
fn execute(
ctx: &mut Self::Context,
plan: &Self::Plan,
alpha: Input::Real,
inputs: &[&Tensor<Input>],
beta: Input::Real,
output: &mut Tensor<Self::Real>,
) -> Result<()>;
fn has_complex_real_support(desc: ComplexRealPrimsDescriptor) -> bool;
}Expand description
Cross-dtype complex-to-real unary protocol family.
The input tensor is complex-valued and the output tensor is real-valued.
§Examples
ⓘ
use num_complex::Complex64;
use tenferro_prims::{
ComplexRealPrimsDescriptor, ComplexRealUnaryOp, CpuBackend, CpuContext,
TensorComplexRealPrims,
};
let mut ctx = CpuContext::new(1);
let desc = ComplexRealPrimsDescriptor::PointwiseUnary {
op: ComplexRealUnaryOp::Abs,
};
let _plan = <CpuBackend as TensorComplexRealPrims<Complex64>>::plan(
&mut ctx,
&desc,
&[&[2, 2], &[2, 2]],
)
.unwrap();Required Associated Types§
Required Methods§
Sourcefn plan(
ctx: &mut Self::Context,
desc: &ComplexRealPrimsDescriptor,
shapes: &[&[usize]],
) -> Result<Self::Plan>
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.
Sourcefn execute(
ctx: &mut Self::Context,
plan: &Self::Plan,
alpha: Input::Real,
inputs: &[&Tensor<Input>],
beta: Input::Real,
output: &mut Tensor<Self::Real>,
) -> Result<()>
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.
The execution contract matches the rest of tenferro prims:
output <- alpha * op(inputs) + beta * output.
Sourcefn has_complex_real_support(desc: ComplexRealPrimsDescriptor) -> bool
fn has_complex_real_support(desc: ComplexRealPrimsDescriptor) -> 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> TensorComplexRealPrims<Input> for CpuBackend
impl<Input> TensorComplexRealPrims<Input> for CpuBackend
Source§impl<Input> TensorComplexRealPrims<Input> for CudaBackend
Available on non-crate feature cuda only.
impl<Input> TensorComplexRealPrims<Input> for CudaBackend
Available on non-crate feature
cuda only.