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

Alias in-place buffers with matching fold factors and strides #604

Merged
merged 6 commits into from
Feb 18, 2025

Conversation

vksnk
Copy link
Collaborator

@vksnk vksnk commented Feb 13, 2025

No description provided.

@vksnk vksnk requested a review from dsharlet February 13, 2025 21:27
@@ -796,8 +797,16 @@ class in_place_aliaser : public stmt_mutator {
}
}

bool fold_factors_strides_same(const std::vector<dim_expr>& dims_a, const std::vector<dim_expr>& dims_b) {
for (std::size_t ix = 0; ix < std::min(dims_a.size(), dims_b.size()); ++ix) {
Copy link
Owner

Choose a reason for hiding this comment

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

I think this check needs to guarantee that the allocation being replaced isn't losing a stride/fold_factor constraint, which it might be if it has more dimensions than the alias target.

Basically, I think this check needs to be aware of which dims are the allocation and which are the alias target, and it needs to verify that all of the allocation strides/fold factors match. I also think maybe if the rank doesn't match, it shouldn't allow any stride/fold factor on the allocation (like HEAD).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the comparison function, PTAL.

Copy link
Owner

@dsharlet dsharlet left a comment

Choose a reason for hiding this comment

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

This looks good, but I think this should have a test in cannot_alias.cc, one of the https://github.com/dsharlet/slinky/blob/main/builder/test/cannot_alias.cc#L15 tests that runs twice: once with a constraint that is unproven that prevents aliasing, and once with a constraint that does prove true and allow aliasing.

@vksnk
Copy link
Collaborator Author

vksnk commented Feb 14, 2025

Fixed the comments and added a test.

@vksnk
Copy link
Collaborator Author

vksnk commented Feb 18, 2025

Review ping.


var x(ctx, "x");

// Here we explicitly use std::functions (in the form of a
Copy link
Owner

Choose a reason for hiding this comment

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

Pass the functions directly? This looks like copy-paste from a different test

@vksnk vksnk merged commit 865f766 into main Feb 18, 2025
1 check passed
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