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

CuIterator assumes batches to consist of multiple arrays #86

Closed
maleadt opened this issue May 1, 2020 · 2 comments
Closed

CuIterator assumes batches to consist of multiple arrays #86

maleadt opened this issue May 1, 2020 · 2 comments
Labels
cuda array Stuff about CuArray. enhancement New feature or request

Comments

@maleadt
Copy link
Member

maleadt commented May 1, 2020

When batching over a single array, stuff goes wrong:

julia> a = CuArrays.ones(10)
10-element CuArray{Float32,1,Nothing}:
 1.0
 1.0
 1.0
 1.0
 1.0
 1.0
 1.0
 1.0
 1.0
 1.0

julia> for (i, batch) in enumerate(CuIterator(Iterators.partition(a, 5)))
       @show i batch
       end
i = 1
batch = Float32[1.0, 1.0, 1.0, 1.0, 1.0]
ERROR: MethodError: no method matching unsafe_free!(::Float32)

The docs should probably also use Iterators.partition, it's a nice way of expressing this.

@maleadt
Copy link
Member Author

maleadt commented May 1, 2020

Workaround:

julia> for (i, (batch,)) in enumerate(CuIterator(map(tuple, Iterators.partition(a, 5))))
       @show i batch
       end
i = 1
batch = Float32[1.0, 1.0, 1.0, 1.0, 1.0]
i = 2
batch = Float32[1.0, 1.0, 1.0, 1.0, 1.0]

@maleadt maleadt transferred this issue from JuliaGPU/CuArrays.jl May 27, 2020
@maleadt maleadt added cuda array Stuff about CuArray. enhancement New feature or request labels May 27, 2020
@maleadt
Copy link
Member Author

maleadt commented Apr 27, 2024

This works now.

@maleadt maleadt closed this as completed Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda array Stuff about CuArray. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant