First program
Start with a small Surf function, format it, check it, then ask the compiler to show the canonical Deep form.
Create app.ch:
def relu_then_softmax(x: tensor[n, f32]) -> tensor[n, f32] = x |> relu |> softmax(0)Then run:
chelis fmt --inplace app.chchelis check app.chchelis deep app.ch > app.dpchelis surf app.dpcheck, deep, and surf are useful together: Surf stays readable for humans, while
Deep is the stable machine form that shell tooling can inspect.
(defsig {} relu_then_softmax (t-fn {} (t-tensor {} (d-name {} n) (t-prim {} f32)) (t-tensor {} (d-name {} n) (t-prim {} f32))))
(def {} relu_then_softmax (fn {} (params {} (x {type: (t-tensor {} (d-name {} n) (t-prim {} f32))})) (pipe {} (var {} x) (var {} relu) (app {} (var {} softmax) (lit {type: (t-prim {} int32)} 0)))))Useful commands
Section titled “Useful commands”Check a program:
chelis check app.chPrint canonical Deep:
chelis deep app.chConvert Deep back to Surf:
chelis surf app.dpBuild source artifacts without invoking a native compiler:
chelis build app.ch --target c --output out/