tokitai-operator 0.1.0

Verified DL kernel compiler: formally-checked GEMM, p-adic, sheaf, contract-carrying ops. Paper-artifact grade.
Documentation
//! `ObjectMeta` and `ObjectKind`.
//!
//! `ObjectMeta` is the per-value metadata: `DomainId`, `Shape`,
//! `Representation`, and any layout flags. `ObjectKind` is the
//! classification (`Tensor`, `Scalar`, `Section`).
//!
//! `ObjectMeta` is the central type that flows through the IR,
//! the planner, the executor, and the verifier. The
//! `ObjectMeta::tensor` constructor is the most common entry
//! point; it builds a tensor-typed meta with a `Representation`
//! (dense CPU, p-adic scalar, etc.).
//!
use crate::domain::DomainId;

use super::{Representation, Shape};

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ObjectKind {
    Tensor,
    Section,
    Sheaf,
    Complex,
    Morphism,
    BundleLike,
    GraphObject,
    Scalar,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Invariant {
    pub description: String,
}

impl Invariant {
    pub fn new(description: impl Into<String>) -> Self {
        Self {
            description: description.into(),
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ObjectMeta {
    pub object_kind: ObjectKind,
    pub domain: DomainId,
    pub shape: Shape,
    pub representation: Representation,
    pub invariants: Vec<Invariant>,
}

impl ObjectMeta {
    pub fn tensor(domain: DomainId, shape: Shape, representation: Representation) -> Self {
        Self {
            object_kind: ObjectKind::Tensor,
            domain,
            shape,
            representation,
            invariants: Vec::new(),
        }
    }
}