Skip to main content

Crate tenferro_runtime

Crate tenferro_runtime 

Source
Expand description

Traced graph runtime and extension dispatch infrastructure for tenferro.

This crate owns graph construction, lowering to execution IR, graph execution, and backend-parametric extension runtime dispatch. Standard operations are lowered through the runtime’s internal operation vocabulary; tensor storage and backend kernels live in tenferro-tensor.

Use this crate directly when you want concrete tensor helpers or reusable traced graph execution without depending on tenferro-ad. Start with TypedTensor when the scalar type is fixed in Rust, Tensor when dtype is selected at runtime, and TracedTensor plus GraphCompiler and Runtime when the same expression should be compiled once and run repeatedly. Operation-family crates such as tenferro-einsum, tenferro-linalg, and tenferro-fft register extension runtimes through runtime engine registrations when compiled execution reaches those operations.

User-facing guides live at https://tensor4all.org/tenferro-rs/guides/choosing-an-api.html and https://tensor4all.org/tenferro-rs/guides/execution-models.html.

§Examples

use tenferro_runtime::{GraphCompiler, Runtime, TracedTensor};
use tenferro_cpu::CpuBackend;

let x = TracedTensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap();
let y = (&x + &x).unwrap();
let mut compiler = GraphCompiler::new();
let program = compiler.compile(&y).unwrap();
let backend = CpuBackend::default();
let mut builder = Runtime::builder();
builder.register_engine(tenferro_cpu::runtime_engine_registration(&backend).unwrap()).unwrap();
let runtime = builder.build().unwrap();
let out = runtime.run_compiled(&program, &[]).unwrap().pop().unwrap();
assert_eq!(out.as_slice::<f64>().unwrap(), &[2.0, 4.0]);

Re-exports§

pub use error::ContextId;
pub use error::Error;
pub use error::ErrorPhase;
pub use error::Result;
pub use error::ShapeConstraintEvalError;
pub use extension_cache::ExtensionCacheKey;
pub use extension_cache::ExtensionCacheLimits;
pub use extension_cache::ExtensionCacheSelector;
pub use extension_cache::ExtensionCacheStore;
pub use graph::CompiledGraph;
pub use graph::GraphCompiler;
pub use runtime::assemble_executable_engine_registration;
pub use runtime::assemble_preparation_only_engine_registration;
pub use runtime::CacheInFlightBehavior;
pub use runtime::CacheOwnerError;
pub use runtime::CacheOwnerFailure;
pub use runtime::CacheOwnerId;
pub use runtime::CoreCapabilityBundle;
pub use runtime::CoreCapabilityBundleBuilder;
pub use runtime::CoreCapabilityKind;
pub use runtime::CorePrepareContext;
pub use runtime::Determinism;
pub use runtime::DotGeneralPreparation;
pub use runtime::DotGeneralPrepareRequest;
pub use runtime::ElementwisePrepareRequest;
pub use runtime::ElementwiseRuntime;
pub use runtime::EngineExecutionContractError;
pub use runtime::EngineId;
pub use runtime::EngineRegistration;
pub use runtime::EngineRegistrationMetadata;
pub use runtime::EngineSnapshotView;
pub use runtime::ErasedExecutionContext;
pub use runtime::EventDomainDriver;
pub use runtime::EventDomainError;
pub use runtime::EventDomainId;
pub use runtime::EventDomainOperation;
pub use runtime::EventDomainRun;
pub use runtime::EventToken;
pub use runtime::ExecutableEngineRegistrationConfig;
pub use runtime::ExecutionContextIdentity;
pub use runtime::ExecutionContextMismatch;
pub use runtime::ExecutionHandle;
pub use runtime::ExecutionPolicy;
pub use runtime::ExecutionPolicyError;
pub use runtime::ExtensionEngine;
pub use runtime::ExtensionModule;
pub use runtime::ExtensionModuleError;
pub use runtime::ExtensionModuleId;
pub use runtime::ExtensionModuleRegistrar;
pub use runtime::ExtensionPlanningConfig;
pub use runtime::ExtensionPrepareRequest;
pub use runtime::HardwareClassId;
pub use runtime::IdentityError;
pub use runtime::IdentityKind;
pub use runtime::ImmediateEventDomainDriver;
pub use runtime::IndexingPrepareRequest;
pub use runtime::IndexingRuntime;
pub use runtime::InputIngressContract;
pub use runtime::InputIngressContractError;
pub use runtime::InputPlacementContract;
pub use runtime::InputSignature;
pub use runtime::InputSignatureContract;
pub use runtime::InputSignatureEntry;
pub use runtime::InputSignatureError;
pub use runtime::InputSpecializationProjection;
pub use runtime::InputSpecializationRequirements;
pub use runtime::InputSpecializationRequirementsBuilder;
pub use runtime::InputSpecializationRequirementsError;
pub use runtime::LayoutClass;
pub use runtime::LayoutPrepareRequest;
pub use runtime::LayoutProjection;
pub use runtime::LayoutRuntime;
pub use runtime::LayoutSpecialization;
pub use runtime::PlacementConstraintError;
pub use runtime::PlacementProjection;
pub use runtime::PlacementSpecialization;
pub use runtime::PreparationKeySummary;
pub use runtime::PreparationOnlyEngineRegistrationConfig;
pub use runtime::PrepareCapability;
pub use runtime::PrepareError;
pub use runtime::PrepareOptions;
pub use runtime::PrepareOptionsKey;
pub use runtime::PreparedCompiledGraph;
pub use runtime::PreparedOperation;
pub use runtime::PreparedOperationBinding;
pub use runtime::PreparedOperationHandle;
pub use runtime::PreparedOperationPlan;
pub use runtime::PreparedPlanCacheLimits;
pub use runtime::PreparedPlanCacheStats;
pub use runtime::ProgramPlacementConstraint;
pub use runtime::ProviderContractError;
pub use runtime::ProviderDeviceIdentity;
pub use runtime::ProviderId;
pub use runtime::RankRequirement;
pub use runtime::ReductionPrepareRequest;
pub use runtime::ReductionRuntime;
pub use runtime::RegistrationIdentity;
pub use runtime::RegistrationKey;
pub use runtime::ResidentOutputContract;
pub use runtime::ResolvedPlanningConfig;
pub use runtime::ResolvedPlanningKey;
pub use runtime::ResolvedProgramPlacement;
pub use runtime::Runtime;
pub use runtime::RuntimeCacheError;
pub use runtime::RuntimeCacheOwner;
pub use runtime::RuntimeCacheStats;
pub use runtime::RuntimeConfigBuilder;
pub use runtime::RuntimeConfigError;
pub use runtime::RuntimeConfigSnapshot;
pub use runtime::RuntimeEpoch;
pub use runtime::RuntimeId;
pub use runtime::RuntimeInputContract;
pub use runtime::RuntimeReconfiguration;
pub use runtime::RuntimeReconfigureError;
pub use runtime::RuntimeStateError;
pub use runtime::SpecializationError;
pub use runtime::SpecializationProjection;
pub use runtime::SpecializationRequirements;
pub use runtime::StorageClass;
pub use runtime::SubmissionError;
pub use runtime::TransferEndpoint;
pub use runtime::TransferError;
pub use runtime::TransferProvider;
pub use runtime::TransferProviderContractError;
pub use runtime::TransferRequest;
pub use runtime::UnsupportedReason;
pub use traced::TracedTensor;

Modules§

error
Error types for the tenferro runtime crate.
extension
Public surface for out-of-tree extension primitives.
extension_cache
Generic runtime caches for extension executors.
graph
Graph compilation APIs.
program
Immutable backend-neutral semantic programs.
runtime
sym_dim
traced

Structs§

CacheStats
Entry, retained-byte, and event accounting for one cache.
CompilerOptions
DotGeneralConfig
DotGeneral dimension configuration.
ExtensionExecutionContext
Backend and cache state passed to one prepared extension execution.
GatherConfig
StableHLO gather dimension configuration.
OptimizerConfig
PadConfig
StableHLO pad configuration.
ScatterConfig
StableHLO scatter dimension configuration.
SliceConfig
Slice configuration.
SymDim
A symbolic tensor dimension expression used to build shape-agnostic graphs.
TraceContext
Mutable owner of one backend-neutral semantic trace.
TraceValue
Opaque value handle owned by one TraceContext.
TracedGraph
Immutable backend-neutral output of one completed trace.
TracedSliceBuilder
Rank-preserving traced tensor slicing builder.
TypedTensor
Runtime typed tensor storage with compile-time scalar type and rank metadata.
TypedTensorView
Read-only borrowed view of typed tensor storage with arbitrary strides.

Enums§

CompareDir
Comparison direction.
DType
Runtime scalar dtype tag.
MemoryKind
Memory location for tensor storage.
ShapeRelation
A relation between two symbolic shape expressions.
Tensor
Dynamic tensor enum over the supported scalar types.
TensorRead
Read-only tensor input accepted by synchronous eager kernels.
TensorValue
Owned tensor value that can be compact or a lazy view.
TensorView
Dynamic read-only borrowed tensor view.

Traits§

BackendSessionHost
Backend execution-session entry points.
TensorBackend
Standard runtime backend over dynamic Tensor values.
TensorOpsExt
Backend-explicit concrete tensor operations.
TensorScalar
Sealed trait for scalar types that can be stored in a Tensor.
TypedTensorMaskOpsExt
Backend-explicit bool-mask operations for typed tensors.
TypedTensorOpsExt
Backend-explicit operations for dynamic-rank typed tensors.