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

getobs!(buffer, data::BatchView, idx) ignores buffer #156

Open
jondeuce opened this issue May 19, 2023 · 0 comments · May be fixed by #157
Open

getobs!(buffer, data::BatchView, idx) ignores buffer #156

jondeuce opened this issue May 19, 2023 · 0 comments · May be fixed by #157

Comments

@jondeuce
Copy link

jondeuce commented May 19, 2023

For example,

using MLUtils
buffer = zeros(3,2)
data = BatchView(rand(3,100); batchsize = 2)
getobs!(buffer, data, 1)
buffer == zeros(3,2) # true

Looks like it just falls back to getobs defined here. This leads to e.g. DataLoader never calling getobs! when batchsize > 0:

struct DummyData{X}
    x::X
end
MLUtils.numobs(data::DummyData) = numobs(data.x)
MLUtils.getobs(data::DummyData, idx) = getobs(data.x, idx)
MLUtils.getobs!(buffer, data::DummyData, idx) = error("getobs! is called")

data = DummyData(rand(3,100))
collect(DataLoader(data; batchsize=1, buffer=true)) # no error
collect(DataLoader(data; batchsize=0, buffer=true)) # error
@CarloLucibello CarloLucibello linked a pull request May 19, 2023 that will close this issue
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 a pull request may close this issue.

1 participant