Files
fvnn-minijax/src/interpreters/eval.rs
T

25 lines
620 B
Rust
Raw Normal View History

2026-05-26 10:24:33 +02:00
use crate::{
core::{Primitive, Value},
interpreters::Interpreter,
};
struct EvalInterpreter {}
impl Interpreter for EvalInterpreter {
fn process_primitive(&mut self, primitive: Primitive) -> Box<dyn Value> {
use Primitive::*;
Box::new(match primitive {
Neg(x) => -x,
Reciprocal(x) => 1. / x,
Add(x, y) => x + y,
Mul(x, y) => x * y,
Sq(x) => x * x,
Sqrt(x) => x.sqrt(),
Ln(x) => x.ln(),
Exp(x) => x.exp(),
Dot(A, B) => A.dot(&B),
ReLU(x) => x.max(0.),
})
}
}