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

Array algebra iter const #445

Merged
merged 5 commits into from
Apr 8, 2021
Merged

Conversation

weiya711
Copy link
Contributor

@weiya711 weiya711 commented Apr 7, 2021

The code fixes to the array algebra iteration lattice construction algorithm.

It is now passing all of the tests in make test and furthermore is creating the correct output for many other fused iteration spaces being tested in tensor-compiler/array-programming-benchmarks.

I would like to add those fused benchmarks in as tests to tests-merge_lattice.cpp and tests-lower.cpp but will do that after 4/16/20

@weiya711 weiya711 requested a review from rawnhenry April 7, 2021 23:17
@weiya711
Copy link
Contributor Author

weiya711 commented Apr 8, 2021

I am going to merge this anyways since it is needed to fix a benchmarking bug. Hopefully @RawnH can review it later.

@weiya711 weiya711 merged commit bc765ba into array_algebra Apr 8, 2021
@weiya711 weiya711 deleted the array_algebra_iter_const branch April 8, 2021 09:46
Copy link
Collaborator

@rawnhenry rawnhenry left a comment

Choose a reason for hiding this comment

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

Thanks so much for this @weiya711. Looks great! I just have a couple of mainly stylistic questions inline

// Append all combinations of the merge points of a and b
auto sorted_apoint = left.points();
auto sorted_bpoint = right.points();
std::sort(sorted_apoint.begin(), sorted_apoint.end(), pointSorter);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Aren't the lattice points already sorted? Why do we need to sort again here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With my new algorithmic changes there were differences in the ordering of points causing tests-merge_latticce.cpp to fail in two tests even though the lattices were the same. It permuted some of the points on the same-level. This was the easiest way for me to fix it, but I'm also open to other suggestions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I remember dealing with that. Seems like a good solution to me.

auto bpoint_set = bpoint.tensorRegion();

for (auto& it : apoint_set) {
if (!std::count(bpoint_set.begin(), bpoint_set.end(), it) &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Low priority, but can these use the taco::util::contains instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, the std::count() online was the preferred method, but taco::util::contains makes more sense to the programmer reading the code.

auto bpoint_set = bpoint.tensorRegion();

for (auto& it : apoint_set) {
if (!std::count(bpoint_set.begin(), bpoint_set.end(), it) &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question as above about using util::contains

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will change this and push directly to array_algebra when I have time. Same as above.

auto apoints = a.points();
auto bpoints = b.points();
struct pointSort {
bool operator()(const MergePoint& a, const MergePoint& b) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question about sorting. I think the MergeLattice's points should always be sorted so it seems strange that we need to sort before a comparison

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above. You sorted before in the original unionLattices(...) anyways when taking the cartesian product so I just took the code from there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, I was just wondering why a sort inside one of the MergeLattice operators since the points should always be sorted. But as above, I also ran into the issue of points on the same level being permuted.

I think this is fine.

{
vector<Iterator> result;

// Remove all but one of the dense iterators, which are all the same.
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are removing all of the dimension iterators right? Not all but one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea. This was a comment I copied from your deduplicateDImensionIterators(...) function. This comment is wrong, but the code should remove all dense iterators. I will fix this in the same commit when I change the code to taco::util::contains

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