-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Complete register op from python #8079
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
Conversation
also cc @FrozenGene please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xqdan Thanks a lot for this PR.
I'd really like to complete registering ops from python.
Some discussions are in RFC 9903.
The major problem (why I didn't complete it at once) is that the TypeRelation
currently is pure C++ with very limited FFI.
Also, need to think about how to use TypeReporter while InferType
from python?
1, We may need to expose some basic TypeRelation function without TypeReporter . |
@zackcquic please take another look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the PR, being able to register ops fully in python is a great tool for prototyping. I have a few concerns for this approach though:
- IMO, we should emphasize this python API strictly for user prototyping and not for any checked in code, since the type function exposed through FFI is not the C++ type relation (it's strictly weaker since we don't have access to the type reporter, and cannot propagate constraints to the inputs, only to the output). We should probably not use "type relation" to describe the python API but I'm not sure what other name to use.
- Related to the previous point, the python API (at least currently) does not have access to diagnostics for reporting type errors, which is not good for user experience (indeed we're trying to port ICHECKs to diagnostics where possible).
Ideally we should expose all the machinery needed but for prototyping it might not be necessary. cc @jroesch for thoughts
Since we still call C++ type relation funcs underhood(such as test_custom_op_infer), I keep the name but add more comments in python api, is it ok?
Let me try add a case for python exceptions.
|
@altanh @zackcquic @ZihengJiang please take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR overall looks good. One question is, is there any support or have you thought about to register TVMCompute via such API?
Thanks for your review, @ZihengJiang Do you mean this? Line 171 in 8131364
Since we can define custom op thru tvm compute in python, and we can register it in python, I think it's ok for now. |
Hi @xqdan , I am thinking to use relay IR and TE in a hybrid way but that might beyond this PR. I will approve it and wait to see if @altanh and @zackcquic have any opinion for your updated changes. |
Thanks @ZihengJiang
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @xqdan,
Sorry for the late reply.
This PR is very useful.
(Actually I already use this PR to do some experiments, thanks a lot 👍)
I am wondering if you have plan to make it more like C++ API (eg export TypeReporter, etc).
I agree with @altanh, should clarify what is done and what is not done, so users could quickly catch up.
I can only think about adding comments/documents, maybe you and others may come up with better idea?
Thanks for review. @zackcquic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @xqdan.
Merged. Thanks @xqdan |
* Complete register op from python * fix lint * fix lint * fix lint * fix comments * fix * fix * fix comments * fix lint * fix lint * add comments * fix build * fix * add exception case * fix * fix comments * fix * fix * fix * fix * fix * fix * fix Co-authored-by: xiaoqiang.dan <xiaoqiang.dan@streamcoputing.com>
* Complete register op from python * fix lint * fix lint * fix lint * fix comments * fix * fix * fix comments * fix lint * fix lint * add comments * fix build * fix * add exception case * fix * fix comments * fix * fix * fix * fix * fix * fix * fix Co-authored-by: xiaoqiang.dan <xiaoqiang.dan@streamcoputing.com>
Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.
This is a following up PR based on #8002
1, Support add_type_rel() and others in python
2, Make register op utilities exposed under relay.op
@zackcquic @tqchen