-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve type-stability for metrices #233
Conversation
Codecov Report
@@ Coverage Diff @@
## master #233 +/- ##
=========================================
Coverage ? 68.92%
=========================================
Files ? 24
Lines ? 1860
Branches ? 0
=========================================
Hits ? 1282
Misses ? 578
Partials ? 0
Continue to review full report at Codecov.
|
Timings on a M6000:
This is just an arbitrary network I have been working on, but the results are quite stark |
@pluskid We can also drop the last two commits |
end | ||
|
||
function get(metric :: MSE) | ||
return [(:MSE, metric.mse_sum / metric.n_sample)] | ||
# Delay copy until last possible moment | ||
mse_sum = mapreduce(nda->copy(nda)[1], +, 0.0, metric.mse_sum) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that each NDArray
in mse_sum
at this point are actually scalars? Maybe using asscalar
will be more efficient than the generic copy
function. Otherwise, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asscalar
only exist on the python side and is uses the same mechanism. We could probably write a more effective mechanism with an unsafe_load
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. OK. Sounds good then.
_update_single_output
needs to be type-stable, therefore move@nd_as_jl
over the function barrier