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

Add for in syntax for immutable arrays, tensors and slices #119

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

wingertge
Copy link
Contributor

Adds for item in array syntax for &Array, &Tensor and Slice. This currently only implements immutable iterators until we can figure out a way to implement mutable references into arrays.

Testing

Adds a frontend and a runtime test to ensure it works properly.

_context: &mut CubeContext,
_body: impl FnMut(&mut CubeContext, <T::Item as CubeType>::ExpandType),
) {
unimplemented!("Can't unroll array iterator")
Copy link
Member

Choose a reason for hiding this comment

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

it would be cool to support unroll. I guess we would need a way to know if the len is comptime as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately there currently isn't infrastructure for that. Could make it work for shared memory and local arrays in theory, but we'd need to add the comptime size to the ExpandElement or something like that to read it in the iterator.

@nathanielsimard nathanielsimard merged commit 230ab97 into tracel-ai:main Sep 14, 2024
2 of 5 checks passed
@wingertge wingertge deleted the for-in branch September 23, 2024 20:31
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.

2 participants