TensorSemiringCore

Trait TensorSemiringCore 

Source
pub trait TensorSemiringCore<Alg: Semiring> {
    type Plan;
    type Context;

    // Required methods
    fn plan(
        ctx: &mut Self::Context,
        desc: &SemiringCoreDescriptor,
        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<()>;
}
Expand description

Minimal semiring execution protocol.

§Examples

use tenferro_algebra::Standard;
use tenferro_prims::{CpuBackend, CpuContext, SemiringCoreDescriptor, TensorSemiringCore};

let mut ctx = CpuContext::new(1);
let desc = SemiringCoreDescriptor::MakeContiguous;
let _plan = <CpuBackend as TensorSemiringCore<Standard<f64>>>::plan(
    &mut ctx,
    &desc,
    &[&[2, 2], &[2, 2]],
)
.unwrap();

Required Associated Types§

Source

type Plan

Backend-specific plan type.

Source

type Context

Backend-specific execution context.

Required Methods§

Source

fn plan( ctx: &mut Self::Context, desc: &SemiringCoreDescriptor, shapes: &[&[usize]], ) -> Result<Self::Plan>

Plan a semiring-core operation.

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 semiring-core operation.

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§