This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Python] Add SCFIfOp Python binding
ClosedPublic

Authored by chhzh123 on Mar 6 2022, 12:07 PM.

Details

Summary

Current generated Python binding for the SCF dialect does not allow
users to call IfOp to create if-else branches on their own.
This PR sets up the default binding generation for scf.if operation
to address this problem.

Diff Detail

Event Timeline

chhzh123 created this revision.Mar 6 2022, 12:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2022, 12:07 PM
chhzh123 requested review of this revision.Mar 6 2022, 12:07 PM
ftynse requested changes to this revision.Mar 7 2022, 1:20 AM

Thanks! This looks almost good. Could you please add a test?

mlir/python/mlir/dialects/_scf_ops_ext.py
72–78

I would rather use the following signature: self, cond, results_ = [], *, hasElse=False, loc=None, ip=None). This will (1) make it easy to create if operations that don't return values (most cases I've seen so far) and (2) require passing hasElse using kwargs syntax as opposed to just having magic True in the call.

81

"a boolean value" can be misinterpreted as Python True/False.

This revision now requires changes to proceed.Mar 7 2022, 1:20 AM
chhzh123 updated this revision to Diff 413518.Mar 7 2022, 9:18 AM

Fix signature and add tests

Herald added a reviewer: sstefan1. · View Herald Transcript
Herald added a reviewer: herhut. · View Herald Transcript
Herald added a reviewer: rriddle. · View Herald Transcript
Herald added a reviewer: aartbik. · View Herald Transcript
Herald added a reviewer: jpienaar. · View Herald Transcript
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a reviewer: aartbik. · View Herald Transcript
Herald added a reviewer: aartbik. · View Herald Transcript
Herald added projects: Restricted Project, Restricted Project, Restricted Project, Restricted Project, Restricted Project, Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript

Oh seems I made a wrong merge from the master branch.

chhzh123 updated this revision to Diff 413528.Mar 7 2022, 9:39 AM

Fix function signature and add tests

jrtc27 removed a subscriber: jrtc27.Mar 7 2022, 9:40 AM
clementval removed a project: Restricted Project.Mar 7 2022, 9:44 AM
ormris removed a subscriber: ormris.Mar 7 2022, 9:52 AM
ormris added a subscriber: ormris.
chhzh123 marked 2 inline comments as done.Mar 7 2022, 9:53 AM

@ftynse Sorry for messing up this PR a bit. I've made the changes you suggested. Please have a check. Thanks!

ormris removed a subscriber: ormris.Mar 7 2022, 9:57 AM
jhenderson resigned from this revision.Mar 7 2022, 9:50 PM
foad removed a subscriber: foad.Mar 8 2022, 1:14 AM
ldionne removed a reviewer: Restricted Project.Mar 8 2022, 6:12 AM
ldionne removed a project: Restricted Project.
ldionne removed a subscriber: libcxx-commits.

Hi @ftynse , could you please take a look at it and see if there is anything that should be changed? Thanks!

ftynse accepted this revision.Mar 11 2022, 1:39 AM

Thanks! Let me know if you need help landing this.

This revision is now accepted and ready to land.Mar 11 2022, 1:39 AM
ftynse removed projects: Restricted Project, Restricted Project, Restricted Project, Restricted Project.Mar 11 2022, 1:40 AM

@ftynse Thanks for reviewing! Could you help land the PR? Seems I do not have access rights to push to the main repository.

Can you rebase? Your patch does not apply apparently

chhzh123 updated this revision to Diff 414847.Mar 12 2022, 8:32 AM

Rebase 3 commits

chhzh123 updated this revision to Diff 414852.Mar 12 2022, 8:55 AM

Try rebasing again

I've rebased to the latest commit in the main branch, but the pre-merge checks still failed.

Seems like there is a local base commit in your repository: you're not uploading a diff that applies on HEAD.

Passed pre-merge checks. Should be able to be merged. Thanks!

This revision was automatically updated to reflect the committed changes.