Packages

MLX machine learning framework bindings for Erlang

Current section

Files

Jump to
mlx src quick_test.erl
Raw

src/quick_test.erl

-module(quick_test).
-export([run/0]).
run() ->
io:format("=== Quick MLX Test ===~n"),
% Test basic functionality
try
io:format("Testing basic array creation...~n"),
case catch test_basic_arrays() of
ok ->
io:format("✓ Basic arrays: PASS~n");
Error1 ->
io:format("✗ Basic arrays: FAIL - ~p~n", [Error1])
end,
io:format("Testing neural network operations...~n"),
case catch test_nn_ops() of
ok ->
io:format("✓ Neural network ops: PASS~n");
Error2 ->
io:format("✗ Neural network ops: FAIL - ~p~n", [Error2])
end,
io:format("Testing random generation...~n"),
case catch test_random_ops() of
ok ->
io:format("✓ Random operations: PASS~n");
Error3 ->
io:format("✗ Random operations: FAIL - ~p~n", [Error3])
end,
io:format("~n=== Test Complete ===~n")
catch
Class:Reason:Stacktrace ->
io:format("Test crashed: ~p:~p~n~p~n", [Class, Reason, Stacktrace])
end.
test_basic_arrays() ->
% Test if we can create basic arrays
{ok, A} = mlx:zeros([3, 3]),
{ok, B} = mlx:ones([3, 3]),
{ok, C} = mlx:add(A, B),
{ok, [3, 3]} = mlx:shape(C),
ok.
test_nn_ops() ->
% Test neural network operations
{ok, X} = mlx:random([10, 5]),
{ok, Y} = mlx_nn:relu(X),
{ok, Z} = mlx_nn:softmax(Y),
{ok, [10, 5]} = mlx:shape(Z),
ok.
test_random_ops() ->
% Test random operations
{ok, R1} = mlx_random:normal([100]),
{ok, R2} = mlx_random:uniform([50, 2]),
{ok, [100]} = mlx:shape(R1),
{ok, [50, 2]} = mlx:shape(R2),
ok.