use crate::{ core::{Primitive, Value}, interpreters::Interpreter, }; struct EvalInterpreter {} impl Interpreter for EvalInterpreter { fn process_primitive(&mut self, primitive: Primitive) -> Box { 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.), }) } }