TensorAnalyticPrims

Trait TensorAnalyticPrims 

Source
pub trait TensorAnalyticPrims<Alg: Algebra> {
    type Plan;
    type Context;

    // Required methods
    fn plan(
        ctx: &mut Self::Context,
        desc: &AnalyticPrimsDescriptor,
        shapes: &[&[usize]],
    ) -> Result<Self::Plan>;
    fn execute(
        ctx: &mut Self::Context,
        plan: &Self::Plan,
        alpha: Alg::Scalar,
        inputs: &[&Tensor<Alg::Scalar>],
        beta: Alg::Scalar,
        output: &mut Tensor<Alg::Scalar>,
    ) -> Result<()>;
    fn has_analytic_support(desc: AnalyticPrimsDescriptor) -> bool;
}
Expand description

Analytic pointwise and reduction protocol family.

§Examples

use tenferro_algebra::Standard;
use tenferro_prims::{AnalyticPrimsDescriptor, AnalyticUnaryOp, CpuBackend, CpuContext, TensorAnalyticPrims};

let mut ctx = CpuContext::new(1);
let desc = AnalyticPrimsDescriptor::PointwiseUnary {
    op: AnalyticUnaryOp::Sqrt,
};
let _plan = <CpuBackend as TensorAnalyticPrims<Standard<f64>>>::plan(
    &mut ctx,
    &desc,
    &[&[2, 2], &[2, 2]],
)
.unwrap();

Required Associated Types§

Required Methods§

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.

Public vocabulary may be broader than the currently wired execution surface so later backend work can land without descriptor churn.

Source

fn execute( ctx: &mut Self::Context, plan: &Self::Plan, alpha: Alg::Scalar, inputs: &[&Tensor<Alg::Scalar>], beta: Alg::Scalar, output: &mut Tensor<Alg::Scalar>, ) -> Result<()>

Execute a previously planned analytic-family operation.

The execution contract matches the rest of tenferro prims: output <- alpha * op(inputs) + beta * output.

Source

fn has_analytic_support(desc: AnalyticPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.

This is a family-level capability check and does not validate every shape-specific precondition.

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§