-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Upsampling Layer for Flux #95
Conversation
Co-Authored-By: staticfloat <[email protected]>
Co-Authored-By: staticfloat <[email protected]>
Co-Authored-By: staticfloat <[email protected]>
Co-Authored-By: staticfloat <[email protected]>
Co-Authored-By: staticfloat <[email protected]>
I think it would be good to have this mimic the behavior of the rest of the methods in NNlib post-#94. What I mean by that is:
|
@staticfloat I did manage to address the issues you mentioned. But I ended up messing up the performance badly. The previous benchmarks now show: BenchmarkTools.Trial:
memory estimate: 306.93 MiB
allocs estimate: 5940030
--------------
minimum time: 1.137 s (2.52% GC)
median time: 1.159 s (2.47% GC)
mean time: 1.174 s (4.51% GC)
maximum time: 1.214 s (7.45% GC)
--------------
samples: 5
evals/sample: 1 |
Oh wow, that's pretty disappointing. I'm currently brushing up #94, looking into performance problems there as well, so once I am satisfied with that and we merge it in, I'll swing around to this. I bet it's something simple. Thanks for the update, the structure of this code looks much better. :) |
I'm using the following approach to achieve upsampling. Basically, we iterate over all possible index grids in the new array where we can assign the original array. The backward pass is symmetrical, so all the index grids can be reused. function upsample(x, ratio)
y = similar(x, (size(x) .* ratio)...)
for i in Iterators.product(Base.OneTo.(ratio)...)
loc = map((i,r,s)->range(i, stop = s, step = r), i, ratio, size(y))
@inbounds y[loc...] = x
end
y
end x = rand(100, 100, 3, 1);
@benchmark repeat($x, inner=(3, 3, 1, 1))
@benchmark upsample($x, (3, 3, 1, 1))
|
+1 |
1 similar comment
+1 |
Stuff to do before it is ready to merge
This only supports 2d arrays.
Corresponding CuArrays PR: JuliaGPU/CuArrays.jl#239
Performance Gains over
Base.repeat
Results
upsample
Base.repeat