-
Notifications
You must be signed in to change notification settings - Fork 32
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
fix mul! for JOLI operator and judiVector #114
Conversation
Codecov Report
@@ Coverage Diff @@
## master #114 +/- ##
==========================================
- Coverage 82.42% 82.39% -0.04%
==========================================
Files 24 24
Lines 1861 1863 +2
==========================================
+ Hits 1534 1535 +1
- Misses 327 328 +1
Continue to review full report at Codecov.
|
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 get what the aim is but it's not done correctly
@@ -174,7 +174,7 @@ adjoint(L::LazyScal) = LazyScal(L.s, adjoint(L.P)) | |||
|
|||
mul!(out::SourceType{T}, F::judiPropagator{T, O}, q::SourceType{T}) where {T<:Number, O} = begin y = F*q; copyto!(out, y) end | |||
mul!(out::SourceType{T}, F::judiPropagator{T, O}, q::Vector{T}) where {T<:Number, O} = begin y = F*q; copyto!(out, y) end | |||
mul!(out::SourceType{T}, F::joLinearFunction{T, T}, q::SourceType{T}) where {T<:Number} = begin y = F*q; copyto!(out, y) end | |||
mul!(out::Union{SourceType{T1},SourceType{T2}}, F::joAbstractLinearOperator{T2, T1}, q::SourceType{T2}) where {T1<:Number, T2<:Number} = begin y = F*q; copyto!(out, y) 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.
No this is wrong has to be T1 to match F
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.
Seems there is a problem in IterativeSolvers.jl JuliaLinearAlgebra/IterativeSolvers.jl#313 correct me if I am wrong
src/TimeModeling/Types/abstract.jl
Outdated
(msv::judiMultiSourceVector{T})(x::Vector{T}) where {T<:AbstractFloat} = x | ||
(msv::judiMultiSourceVector{T})(x::judiMultiSourceVector{T}) where {T} = x | ||
(msv::judiMultiSourceVector{mT})(x::Vector{T}) where {mT, T<:Array} = begin y = deepcopy(msv); y.data .= x; return y end | ||
(msv::judiMultiSourceVector{mT})(x::AbstractVector{T}) where {mT<:Number, T<:Number} = x |
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.
No have to match and you are removing a case
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.
judiMultiSourceVector{T}
is AbstractVector
so it includes the both cases already
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.
The type has to match mT!=T
is not valid.
(msv::judiMultiSourceVector{T})(x::judiMultiSourceVector{T}) where {T} = x | ||
(msv::judiMultiSourceVector{mT})(x::Vector{T}) where {mT, T<:Array} = begin y = deepcopy(msv); y.data .= x; return y end | ||
(msv::judiMultiSourceVector{mT})(x::AbstractVector{T}) where {mT<:Number, T<:Number} = x | ||
(msv::judiMultiSourceVector{mT})(x::AbstractVector{T}) where {mT, T<:Array} = begin y = deepcopy(msv); y.data .= x; return y 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.
same
@@ -172,6 +172,20 @@ ylabel("Depth (m)") | |||
title("RTM image") | |||
display(fig) | |||
|
|||
#' notice that we can conduct a simplistic least-squares reverse-time migration via LSQR thanks to the linear algebraic abstraction |
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.
Completely wrong file please make an effort
@@ -174,7 +174,8 @@ adjoint(L::LazyScal) = LazyScal(L.s, adjoint(L.P)) | |||
|
|||
mul!(out::SourceType{T}, F::judiPropagator{T, O}, q::SourceType{T}) where {T<:Number, O} = begin y = F*q; copyto!(out, y) end | |||
mul!(out::SourceType{T}, F::judiPropagator{T, O}, q::Vector{T}) where {T<:Number, O} = begin y = F*q; copyto!(out, y) end | |||
mul!(out::SourceType{T}, F::joLinearFunction{T, T}, q::SourceType{T}) where {T<:Number} = begin y = F*q; copyto!(out, y) end | |||
mul!(out::Union{SourceType{T1},SourceType{T2}}, F::joAbstractLinearOperator{T2, T1}, q::SourceType{T2}) where {T1<:Number, T2<:Number} = begin y = F*q; copyto!(out, y) end | |||
mul!(out::Union{SourceType{T1},SourceType{T2}}, F::joAbstractLinearOperator{T2, T1}, q::Array{T2, N}) where {T1<:Number, T2<:Number, N} = begin y = F*q[:]; copyto!(out, y) 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.
JoAbstractLinearOperator is too general
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.
- What's the potential problem of being too general?
- It should at least contain the
joLinearOperator
andjoLinearFunction
examples/scripts/splsrtm_2D.jl
Outdated
title("LS-RTM with SGD"); xlabel("Lateral position [km]"); ylabel("Depth [km]") | ||
title("SPLS-RTM with SGD"); xlabel("Lateral position [km]"); ylabel("Depth [km]") | ||
|
||
#' LSQR |
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.
Can you please try to make a proper example. It's supposed to help new users so hiding this at the bottom of a file about sparsity isn't very friendly.
4489654
to
a2360a4
Compare
examples/scripts/lsrtm_2D.jl
Outdated
niter = parse(Int, get(ENV, "NITER", "10")) | ||
lsqr_sol = zeros(Float32, prod(n)) | ||
Ml = judiMarineTopmute2D(30, d_lin[1].geometry) | ||
lsqr!(lsqr_sol, Ml*J[1]*Mr, Ml*d_lin[1]; maxiter=niter) # only invert the first shot record |
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.
Why only the first?
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.
otherwise too long time in CI
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.
This is an example, not a test you can't hardcode stuff like that in it. Like if anyone runs that the results is gonna look like JUDI produces shit.
src/TimeModeling/Types/abstract.jl
Outdated
(msv::judiMultiSourceVector{T})(x::Vector{T}) where {T<:AbstractFloat} = x | ||
(msv::judiMultiSourceVector{T})(x::judiMultiSourceVector{T}) where {T} = x | ||
(msv::judiMultiSourceVector{mT})(x::Vector{T}) where {mT, T<:Array} = begin y = deepcopy(msv); y.data .= x; return y end | ||
(msv::judiMultiSourceVector{mT})(x::AbstractVector{T}) where {mT<:Number, T<:Number} = x |
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.
The type has to match mT!=T
is not valid.
Without JUDI.jl/test/test_linear_algebra.jl Line 101 in e22998d
is not passing. I do think we need to add this because again x and msv might live in different space.
|
Then need to be added but properly:
|
aa59d06
to
5835aed
Compare
any other comment on this one? |
examples/scripts/lsrtm_2D.jl
Outdated
niter = parse(Int, get(ENV, "NITER", "10")) | ||
lsqr_sol = zeros(Float32, prod(n)) | ||
|
||
# only invert for the randomly picked indices so that this example can run a bit faster |
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.
You are still hardoding a "want CI to run fast" into a user example. The default new user who runs it should get a decent result and the example produce a result, not "just run".
Hmm the memory blows up in the CI test https://github.com/slimgroup/JUDI.jl/runs/7285219825?check_suite_focus=true any suggestion? |
Correct me if wrong but this parallelization seems to be the culprit
|
I have no idea why this would be related to it this just reduces results pair by pairs. |
Also once again, please learn to |
867f9d4
to
d4d1aab
Compare
This PR makes
work. Especially this works when
Mr
takes complex input (e.g. debiasing for curvelet)