Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
add tests for stateless_apply
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianM-C committed Feb 23, 2024
1 parent 8d9b57e commit 5611f0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/LuxCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ apply(model::AbstractExplicitLayer, x, ps, st) = model(x, ps, st)
Calls `apply` and only returns the first argument.
"""
function stateless_apply(model::AbstractExplicitLayer, x, ps, st)
first(apply(model, x, ps, st))
return first(apply(model, x, ps, st))
end

function stateless_apply(model, x, ps, st)
Expand Down
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ end

@test LuxCore.apply(model, x, ps, st) == model(x, ps, st)

@test LuxCore.stateless_apply(model, x, ps, st) ==
first(LuxCore.apply(model, x, ps, st))

@test_nowarn println(model)
end

Expand Down Expand Up @@ -88,6 +91,9 @@ end

@test LuxCore.apply(model, x, ps, st) == model(x, ps, st)

@test LuxCore.stateless_apply(model, x, ps, st) ==
first(LuxCore.apply(model, x, ps, st))

@test_nowarn println(model)

model = Chain2(Dense(5, 5), Dense(5, 6))
Expand All @@ -103,6 +109,9 @@ end

@test LuxCore.apply(model, x, ps, st) == model(x, ps, st)

@test LuxCore.stateless_apply(model, x, ps, st) ==
first(LuxCore.apply(model, x, ps, st))

@test_nowarn println(model)
end

Expand Down

0 comments on commit 5611f0e

Please sign in to comment.