-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
support complex input for upsample #421
Conversation
src/upsample.jl
Outdated
width_scale = T((in_w - 1) // (out_w - 1)) | ||
height_scale = T((in_h - 1) // (out_h - 1)) | ||
#real(T)() and // so that we can handle rationals (super slow) | ||
width_scale =real(T)((in_w - 1) // (out_w - 1)) |
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.
Do you mind extracting out real(T)
as RT
or some like name? Otherwise this 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.
Done
test/upsample.jl
Outdated
for (d, method) in zip([1, 2, 3], [upsample_linear, upsample_bilinear, upsample_trilinear]) | ||
for (k, interp) in zip((2, tuple([2 for i=1:d]...)), [method, upsample_nearest]) | ||
x = randn(Complex{Float32}, (4,8,12)[1:d]..., 1, 1) | ||
xup = interp(x, k) | ||
@test size(xup)[1:d] == (8,16,24)[1:d] | ||
@test real(xup) == interp(real(x), k) | ||
@test imag(xup) == interp(imag(x), k) | ||
|
||
xup = interp(x; size=(8,24,48)[1:d]) | ||
@test size(xup)[1:d] == (8,24,48)[1:d] | ||
@test real(xup) == interp(real(x), size=(8,24,48)[1:d]) | ||
@test imag(xup) == interp(imag(x), size=(8,24,48)[1:d]) | ||
end | ||
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.
for (d, method) in zip([1, 2, 3], [upsample_linear, upsample_bilinear, upsample_trilinear]) | |
for (k, interp) in zip((2, tuple([2 for i=1:d]...)), [method, upsample_nearest]) | |
x = randn(Complex{Float32}, (4,8,12)[1:d]..., 1, 1) | |
xup = interp(x, k) | |
@test size(xup)[1:d] == (8,16,24)[1:d] | |
@test real(xup) == interp(real(x), k) | |
@test imag(xup) == interp(imag(x), k) | |
xup = interp(x; size=(8,24,48)[1:d]) | |
@test size(xup)[1:d] == (8,24,48)[1:d] | |
@test real(xup) == interp(real(x), size=(8,24,48)[1:d]) | |
@test imag(xup) == interp(imag(x), size=(8,24,48)[1:d]) | |
end | |
end | |
for (d, method) in zip(1:3, [upsample_linear, upsample_bilinear, upsample_trilinear]) | |
for (k, interp) in zip((2, ntuple(_ -> 2, d)), [method, upsample_nearest]) | |
x = randn(ComplexF32, (4, 8, 12)[1:d]..., 1, 1) | |
upsize = (8, 16, 24)[1:d] | |
xup = interp(x, k) | |
@test size(xup)[1:d] == upsize | |
@test real(xup) == interp(real(x), k) | |
@test imag(xup) == interp(imag(x), k) | |
upsize = (8, 24, 48)[1:d] | |
xup = interp(x; size=upsize) | |
@test size(xup)[1:d] == upsize | |
@test real(xup) == interp(real(x), size=upsize) | |
@test imag(xup) == interp(imag(x), size=upsize) | |
end | |
end |
One more touch-up
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.
done
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.
Thanks!
support complex input for upsample
The current implementation uses the array input type to convert width/height/.... which creates non-real numbers when the input is complex. This fixes it by using the real type.