Would it be possible to update to 0.4.1 or in the best case to the latest version?
There are a lot of new features and performance improvements, so I would definitely recommend it.
If you are somehow forced to use 0.4.0, we could come up with a solution, which might be slower than the original scatter_add_ one.