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

[Unity][Transform] Handle call_tir_inplace in FuseTIR and FuseOps #16487

Merged
merged 8 commits into from Feb 6, 2024

Conversation

slyubomirsky
Copy link
Contributor

@slyubomirsky slyubomirsky commented Jan 30, 2024

This PR handles in-place PrimFuncs in FuseTIR, namely by propagating the in-place indices. This required a few updates in the two passes but nothing very heavy-duty.

@slyubomirsky slyubomirsky changed the title [Unity][Transform] Handle call_tir_inplace in FuseTIR [Unity][Transform] Handle call_tir_inplace in FuseTIR and FuseOps. Jan 30, 2024
Copy link
Contributor

@Lunderberg Lunderberg left a comment

Choose a reason for hiding this comment

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

Overall, looks good! The main requests for changing are to make it more robust against upstream errors.

tests/python/relax/test_transform_fuse_tir.py Outdated Show resolved Hide resolved
src/relax/transform/fuse_tir.cc Outdated Show resolved Hide resolved
src/relax/transform/fuse_tir.cc Outdated Show resolved Hide resolved
src/relax/transform/fuse_tir.cc Outdated Show resolved Hide resolved
mutator.fused_tir_funcs_.Set(gv, fused_tir);
const auto& [prim_func, indices] = FusedTIRConstructor::GetFusedTIR(mod, gv);
mutator.fused_tir_funcs_.Set(gv, prim_func);
if (!indices.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Using if (indices.size()) instead of if (!indices.empty()) would avoiding double-negatives and make the condition easier to read. (Though, personal preference as if (indices.size()) relies on conversion of non-zero size_t to true.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kind of subjective, I think "not empty" is readable (sounds more like how it would be phrased verbally). I'll change it if you prefer it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably more personal preference, so either works.

src/relax/transform/fuse_tir.cc Outdated Show resolved Hide resolved
tests/python/relax/test_transform_fuse_tir.py Show resolved Hide resolved
tests/python/relax/test_transform_fuse_tir.py Outdated Show resolved Hide resolved
@slyubomirsky slyubomirsky changed the title [Unity][Transform] Handle call_tir_inplace in FuseTIR and FuseOps. [Unity][Transform] Handle call_tir_inplace in FuseTIR and FuseOps Jan 30, 2024
Copy link
Contributor

@Lunderberg Lunderberg left a comment

Choose a reason for hiding this comment

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

Thank you for the changes, and looks good!

@slyubomirsky slyubomirsky merged commit 6a3fadc into apache:main Feb 6, 2024
18 checks 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.

None yet

2 participants