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

Extend chunk to take a Vector of sizes #114

Closed
theabhirath opened this issue Jul 20, 2022 · 3 comments · Fixed by #133
Closed

Extend chunk to take a Vector of sizes #114

theabhirath opened this issue Jul 20, 2022 · 3 comments · Fixed by #133

Comments

@theabhirath
Copy link
Contributor

The last feature we need to achieve parity with PyTorch would be to provide a dispatch of the type chunk(x; sizes::Vector{Int}), which would take in a Vector of integers and split the input into length(sizes) chunks, with the sizes of each chunk according to sizes. This should achieve something like:

julia> a = reshape(collect(1:10), (5, 2))
5×2 Matrix{Int64}:
 1   6
 2   7
 3   8
 4   9
 5  10
julia> collect(chunk(a; dims = 1, sizes = [1, 4]))
[1  6]
[2 7; 3 8; 4 9; 5 10]
@ToucheSir
Copy link
Contributor

ToucheSir commented Jul 20, 2022

Is there a benefit to making this vector over tuple?

@theabhirath
Copy link
Contributor Author

I don't think so, no. Either would be fine. Is there a generic container type that handles both or would have to write out a Union?

@ToucheSir
Copy link
Contributor

Probably a union. I think using generic functions like map would let you share an implementation as well, but I have not tried.

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.

2 participants