Preliminary state
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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.),
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user