-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
make use of conv_bias_act #1302
base: master
Are you sure you want to change the base?
Conversation
Bump |
3bf03a3
to
b9ff9e9
Compare
b9ff9e9
to
7b28f6d
Compare
bors try |
tryBuild failed: |
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.
Bump
@@ -144,7 +144,7 @@ function (c::Conv)(x::AbstractArray) | |||
# ndims(x) == ndims(c.weight)-1 && return squeezebatch(c(reshape(x, size(x)..., 1))) | |||
σ, b = c.σ, reshape(c.bias, ntuple(_->1, length(c.stride))..., :, 1) | |||
cdims = DenseConvDims(x, c.weight; stride=c.stride, padding=c.pad, dilation=c.dilation) | |||
σ.(conv(x, c.weight, cdims) .+ b) | |||
conv_bias_act(x, c.weight, cdims, b, σ) | |||
end | |||
|
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.
conv_bias_act(x, w, cdims::DenseConvDims, b::Zeros, σ) = σ.(conv(x, w, cdims)) | |
function conv_bias_act(x::CuArray, w::CuArray{T}, cdims::DenseConvDims, b::Zeros, σ) where T | |
bz = CUDA.zeros(size(b)...) | |
NNlib.conv_bias_act(x, w, cdims, bz, σ) | |
end |
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.
We need this materialised here since CUDNN expects to get an array here, and the bump in performance over regular Conv calls is enough to justify needing to allocate some memory and quickly putting it back into the pool. We need them 2x speedups on ResNets!
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.
Use reinterpret(reshape, ...)
instead
using the conv_bias_act is an inner implementation detail that should not block v0.12 (especially given the fact that the author is unresponsive) |
Its not an inner detail - |
|
In that case, we should document these assumptions and the tolerences we're okay with in different scenarios. e.g. is |
Well, composition means that we don't need to have wrappers around kernels that effectively compute the raison d'etre for the layer without polluting the namespace/ api. The api to get all the details of a layer for a "function" would be pretty ugly. Its not a big deal for users to broadcast an activation over a |
AIUI, the whole point of If we don't make use of |
Seems sensible for the fast way to be the default, no? Flux surely doesn't guarantee that exact floating-point values will be the same between versions, and it's definitely not a library targeting uses which care a lot about the 16th decimal place. I don't see any discussion of how different this is; if it's more than minor floating point stuff can someone summarise & provide links? If it is e.g. substantially less accurate, then you could argue for some |
CUDA.math_mode, and fastmath etc |
Make use of
conv_bias_act
from FluxML/NNlib.jl#228.Should speed up Convolutional Neural Networks significantly after JuliaGPU/CUDA.jl#321.