Skip to content

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

Merged
slyubomirsky merged 8 commits intoapache:mainfrom
slyubomirsky:fuse-tir-inplace
Feb 6, 2024
Merged

[Unity][Transform] Handle call_tir_inplace in FuseTIR and FuseOps#16487
slyubomirsky merged 8 commits intoapache:mainfrom
slyubomirsky:fuse-tir-inplace

Conversation

@slyubomirsky
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread tests/python/relax/test_transform_fuse_tir.py Outdated
Comment thread src/relax/transform/fuse_tir.cc Outdated
Comment thread src/relax/transform/fuse_tir.cc Outdated
Comment thread src/relax/transform/fuse_tir.cc Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread src/relax/transform/fuse_tir.cc Outdated
Comment thread tests/python/relax/test_transform_fuse_tir.py
Comment thread tests/python/relax/test_transform_fuse_tir.py Outdated
@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
Copy Markdown
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!

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