Attempting to follow Andrej Karpathy's wonderful tutorial and implement micrograd in mojo.
- The
Value
uses reference semantics. - The
Value
's internaldata
,grad
and_prev
use a custom and very basicRC
(reference counting pointer) - this will be migrated to references (and lifetimes) once they are ready in the core language. - Using
traits
to makeValue
ageneric
struct (we introduce atrait
calledGradable
which is basically a type constraint on what is needed on an 'autogradable' type which can be wrapped by ourValue
). Gradable
implementations:-
GradFloat32
-
GradTensorFloat32
-
- The topological sort in
_backward
is using an iterative implementation (nested functions don't currently support recursion) - Primitive test suite (
make test
) (including tests that mimic those of micrograd)
- Follow guide https://docs.modular.com/mojo/manual/get-started
- Opionally use the
devcontaier
make install
make test
make run
make ...
(seeMakeFile
)