-
-
Notifications
You must be signed in to change notification settings - Fork 35
Generalise adjtrans index getter/setters to accept abstract integer type #1482
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1482 +/- ##
==========================================
- Coverage 93.90% 93.89% -0.01%
==========================================
Files 34 34
Lines 15946 15946
==========================================
- Hits 14974 14973 -1
- Misses 972 973 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
For most other abstract matrix types provided by |
| @propagate_inbounds getindex(A::AdjOrTransAbsMat{T}, i::Int, j::Int) where {T} = wrapperop(A)(A.parent[j, i])::T | ||
| @propagate_inbounds setindex!(v::AdjOrTransAbsVec, x, i::Int) = (setindex!(v.parent, _wrapperop(v)(x), i-1+first(axes(v.parent)[1])); v) | ||
| @propagate_inbounds setindex!(A::AdjOrTransAbsMat, x, i::Int, j::Int) = (setindex!(A.parent, _wrapperop(A)(x), j, i); A) | ||
| @propagate_inbounds Base.isassigned(v::AdjOrTransAbsVec, i::Integer) = isassigned(v.parent, i - one(i) + first(axes(v.parent)[one(i)])) |
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 think the uses of one should be replaced by oneunit. These are equivalent for Integers, but oneunit conveys the intent more clearly.
| @propagate_inbounds setindex!(A::AdjOrTransAbsMat, x, i::Integer, j::Integer) = (setindex!(A.parent, _wrapperop(A)(x), j, i); A) | ||
| # AbstractArray interface, additional definitions to retain wrapper over vectors where appropriate | ||
| @propagate_inbounds getindex(v::AdjOrTransAbsVec, ::Colon, is::AbstractArray{Int}) = wrapperop(v)(v.parent[is]) | ||
| @propagate_inbounds getindex(v::AdjOrTransAbsVec, ::Colon, is::AbstractArray{Integer}) = wrapperop(v)(v.parent[is]) |
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.
| @propagate_inbounds getindex(v::AdjOrTransAbsVec, ::Colon, is::AbstractArray{Integer}) = wrapperop(v)(v.parent[is]) | |
| @propagate_inbounds getindex(v::AdjOrTransAbsVec, ::Colon, is::AbstractArray{<:Integer}) = wrapperop(v)(v.parent[is]) |
When writing CUDA.jl kernels, one should favour Int32 indexing for performance. This currently isn't possible when using the adjoint wrapper since this has hard-coded
Inttypes.This PR relaxes these types to use the abstract
Integertype, inline with other parts of the package (e.g. here).