You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The perf of the recurrent neural networks sample is dominated by Array2D.copy as part of DM addiiton as part of pushRec in DiffSharp.
It might be possible to use in-place addition. I'm not entirely sure which addition operation in pushRec is dominating, but in cases like this it looks like in-place addition might be appropriate:
d.A <- d.A + (v :?> DM)
Regardless, you're using Array2D.copy in DiffSharp and that seems to be slower than it should be since it does an initBased. That should be fixed in FSharp.Core. But in the meantime you can do this which seems 4x faster.
#time "on"
let test1() =
let mutable res = Array2D.zeroCreate<float32> 100 100
for i in 0 .. 1000 do
for j in 0 .. 100 do
res <- Array2D.copy res
let test2() =
let mutable res = Array2D.zeroCreate<float32> 100 100
for i in 0 .. 1000 do
for j in 0 .. 100 do
res <- Array2D.copyFast res
test1() // 4.4s
test2() // 0.98s
The text was updated successfully, but these errors were encountered:
The perf of the recurrent neural networks sample is dominated by
Array2D.copy
as part of DM addiiton as part ofpushRec
in DiffSharp.It might be possible to use in-place addition. I'm not entirely sure which addition operation in
pushRec
is dominating, but in cases like this it looks like in-place addition might be appropriate:Regardless, you're using Array2D.copy in DiffSharp and that seems to be slower than it should be since it does an
initBased
. That should be fixed in FSharp.Core. But in the meantime you can do this which seems 4x faster.e.g.
The text was updated successfully, but these errors were encountered: