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

Commit

Permalink
fix!: remove hacky version of outputsize
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Jul 27, 2024
1 parent 2bdb0a0 commit f8a0437
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/LuxCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,20 @@ end
"""
outputsize(layer, x, rng)
Return the output size of the layer. If `outputsize(layer)` is defined, that method
takes precedence, else we compute the layer output to determine the final size.
Return the output size of the layer.
The fallback implementation of this function assumes the inputs were batched, i.e.,
if any of the outputs are Arrays, with `ndims(A) > 1`, it will return
`size(A)[1:(end - 1)]`. If this behavior is undesirable, provide a custom
`outputsize(layer, x, rng)` implementation).
!!! warning "Inconsistent Pre-1.0 Behavior"
Previously it was possible to override this function by defining `outputsize(layer)`.
However, this can potentially introduce a bug that is hard to bypass. See
[this PR](https://github.com/LuxDL/LuxCore.jl/pull/43) for more information.
"""
function outputsize(layer, x, rng)
hasmethod(outputsize, Tuple{typeof(layer)}) && return outputsize(layer)
ps, st = setup(rng, layer)
y = first(apply(layer, x, ps, st))
return __size(y)
Expand Down

0 comments on commit f8a0437

Please sign in to comment.