Skip to content
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

use buffer in BatchView #157

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

use buffer in BatchView #157

wants to merge 2 commits into from

Conversation

CarloLucibello
Copy link
Member

fix #156

This covers only BatchView(...; collate=nothing), I'm not sure how collate=true and collate=false should interact with the buffer so I won't address that here.

@codecov-commenter
Copy link

codecov-commenter commented May 19, 2023

Codecov Report

Merging #157 (661f09e) into main (2677a73) will increase coverage by 0.11%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main     #157      +/-   ##
==========================================
+ Coverage   88.46%   88.57%   +0.11%     
==========================================
  Files          13       15       +2     
  Lines         598      604       +6     
==========================================
+ Hits          529      535       +6     
  Misses         69       69              
Impacted Files Coverage Δ
src/batchview.jl 82.35% <100.00%> (+1.50%) ⬆️

... and 2 files with indirect coverage changes

@ToucheSir ToucheSir requested review from lorenzoh and removed request for ToucheSir May 21, 2023 21:33
Copy link
Contributor

@ToucheSir ToucheSir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM, though I've pulled in Lorenz to answer the questions posed.

Comment on lines +142 to +149
function getobs!(buffer, A::BatchView{TElem, TData, Val{nothing}}, i) where {TElem, TData}
obsindices = _batchindexes(A, i)
return _getbatch!(buffer, A, obsindices)
end

function _getbatch!(buffer, A::BatchView{TElem, TData, Val{nothing}}, obsindices) where {TElem, TData}
return getobs!(buffer, A.data, obsindices)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function getobs!(buffer, A::BatchView{TElem, TData, Val{nothing}}, i) where {TElem, TData}
obsindices = _batchindexes(A, i)
return _getbatch!(buffer, A, obsindices)
end
function _getbatch!(buffer, A::BatchView{TElem, TData, Val{nothing}}, obsindices) where {TElem, TData}
return getobs!(buffer, A.data, obsindices)
end
function getobs!(buffer, A::BatchView{<:Any, <:Any, Val{nothing}}, i)
obsindices = _batchindexes(A, i)
return _getbatch!(buffer, A, obsindices)
end
function _getbatch!(buffer, A::BatchView{<:Any, <:Any, Val{nothing}}, obsindices)
return getobs!(buffer, A.data, obsindices)
end

I think we can avoid overspecializing here

Comment on lines +147 to +149
function _getbatch!(buffer, A::BatchView{TElem, TData, Val{nothing}}, obsindices) where {TElem, TData}
return getobs!(buffer, A.data, obsindices)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would've assumed this also works for collate=true|false, because unlike getobs/_getbatch the caller has already figured out the return type by passing in buffer. Not sure I understand the interface or API contract that well though, so please correct me if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getobs!(buffer, data::BatchView, idx) ignores buffer
3 participants