-
Notifications
You must be signed in to change notification settings - Fork 258
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Unlike NNlib versions, softmax(x) and logsoftmax(x) in CUDA.jl modify their arguments in-place.
To reproduce
The simplest way to confirm it is to look at the code, but for the sake of completeness here's the minimal reproducible example:
using CUDA
using NNlib
x = cu(rand(5, 10))
original_x = copy(x)
softmax(x)
@assert x == original_xPossible fix
It should be easy to fix softmax(), logsoftmax(), ∇softmax() and ∇logsoftmax() by allocating a new array for the result, e.g.:
softmax(x::DenseCuArray{T}; dims=1) where T<:CUDNNFloat =
softmax!(similar(x), x, dims=dims)Right now I'm struggling with another issue stopping me from creating a PR, but I plan to come back to it later.
jeremiedb
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working