tokitai-operator 0.1.0

Verified DL kernel compiler: formally-checked GEMM, p-adic, sheaf, contract-carrying ops. Paper-artifact grade.
Documentation
//! The `Operator` trait and the `OpSignature` data class.
//!
//! An `Operator` is anything that can be inserted into a
//! `SemanticGraph`: it has a stable name, a fixed input/output
//! signature, an `infer` method that produces output metadata, and
//! `required_contracts` / `provided_contracts` sets that the planner
//! reads to discharge obligations.
//!
//! `OpSignature` is the static (compile-time known) part of the
//! signature. The dynamic (runtime-known) part — actual input shapes
//! and domain — flows through `infer`.
//!
//! `LayerBehavior` is the planner's hint for fusion: `Pointwise`,
//! `Global`, etc.
//!
use crate::Result;
use crate::domain::ContractSet;
use crate::object::ObjectMeta;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OpInput {
    pub name: String,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OpOutput {
    pub name: String,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OpSignature {
    pub inputs: Vec<OpInput>,
    pub outputs: Vec<OpOutput>,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum LayerBehavior {
    Pointwise,
    NeighborhoodLocal,
    CoverLocal,
    Global,
    PrecisionLayered,
    ValuationFiltered,
}

pub trait Operator {
    fn name(&self) -> &'static str;
    fn signature(&self) -> OpSignature;
    fn infer(&self, inputs: &[ObjectMeta]) -> Result<Vec<ObjectMeta>>;
    fn required_contracts(&self) -> ContractSet;
    fn provided_contracts(&self) -> ContractSet;
    fn layer_behavior(&self) -> Vec<LayerBehavior>;
}