import py "torch"
// check propagates: the caller decides
fn logits(n int) (str, error?) {
w := check torch.randn([784, 10],
requires_grad: true)
x := check torch.randn([n, 784])
y := check (x @ w)
return check str(y.shape), none
}
// main can act, so it handles
fn main() {
shape, err := logits(32)
if err != none {
print("torch failed: " + err.msg)
return
}
print("logits: " + shape)
}
That is real torch, one import away, with Python's exceptions arriving as typed error values instead of tracebacks. The whole program is checked before any of it runs; no crash originates in nevla.
Errors are values and dropping one is a compile error.
check propagates to the caller; v, err :=
handles at the layer that can act. There is no nil. Dependencies
are declared or the program does not compile. The twenty-minute
crash dies at nevla check, in milliseconds, or not
at all.