mod batch;
mod cells;
mod circuit;
pub mod dsl;
mod emit;
mod gather;
mod numeric;
mod tensor;
mod wire;
pub use batch::{BatchExecutor, LANES};
pub use cells::{CellSpec, Policy, SourceTable, constant, event, input, input_bit, state, state_bit};
pub use circuit::{
BackpropOptions, BooleanGradient, CandidateTable, Circuit, IndexGradient, IndexRead, Macro, OneHotGroup, OpKind,
Operation, OutOfRange, RoundingPointKind,
};
pub use emit::{
CompareOptions, Relation, emit_and, emit_argmax, emit_clamp_exact, emit_compare, emit_compare_with,
emit_first_active, emit_maximum, emit_maximum_exact, emit_minimum, emit_minimum_exact, emit_not, emit_or,
emit_relu, emit_round, emit_select, is_proven_bit,
};
pub use handwired_rs_macros::handwired;
pub use numeric::Range;
pub use tensor::{CompileOptions, GatherCompute, GatherRead, IndexReadRow, TensorExecutor, TensorLayer, TensorProgram};
pub use wire::{Lin, Term, Wire};
#[derive(Clone, Debug, PartialEq)]
pub enum Error {
SourceLength {
expected: usize,
actual: usize,
},
SourceOutOfRange {
wire: Wire,
value: f64,
range: Range,
},
BooleanGradient {
wire: Wire,
},
IndexGradient {
wire: Wire,
},
}
impl std::fmt::Display for Error {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::SourceLength { expected, actual } => {
write!(formatter, "source table has {actual} cells, expected {expected}")
}
Error::SourceOutOfRange { wire, value, range } => write!(
formatter,
"source wire {} is {value}, outside its declared range {}..{}",
wire.index(),
range.min,
range.max
),
Error::BooleanGradient { wire } => {
write!(formatter, "cannot backpropagate through the boolean atom at wire {}", wire.index())
}
Error::IndexGradient { wire } => {
write!(formatter, "cannot backpropagate into the index of the index read at wire {}", wire.index())
}
}
}
}
impl std::error::Error for Error {}