You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/05/31 04:40:48 UTC
[GitHub] [incubator-tvm] comaniac opened a new pull request #5703: [PatternLang] Simplify Pattern API Implementations
comaniac opened a new pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703
For each pattern node, we defined `XXPattern` Python class for the FFI connection. We also define a user-friendly API such as `is_op` to have better user experience. Since `is_XX` APIs are just wrappers to the corresponding `XXPattern` class, this PR simplifies their implementations by turning the APIs to function aliases.
In addition, this PR also makes the following changes:
1. Add `is_constant`, `is_tuple`, and `is_tuple_get_item` APIs.
2. Rename `is_input` to `is_var` to against `is_constant`.
@mbrookhart I'm not quite sure if the second change makes sense to you or not so I intentionally separate it to the second commit. If you prefer `is_input`, I could just simply revert it.
Also cc @masahi
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] comaniac commented on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
comaniac commented on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-636633165
Hmm, docstring is a fair point. One solution I can think of is adding the API description in the docstring of the corresponding class. For example, adding “is_tuple” to the description of “TuplePattern”. I’ll think more tonight.
cc @tqchen in case you have any ideas.
<sub>Sent with <a href="http://githawk.com">GitHawk</a></sub>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] masahi merged pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
masahi merged pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] comaniac commented on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
comaniac commented on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-636985743
Sure I can do that as well in this PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] masahi commented on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-637192655
Thanks @comaniac @mbrookhart @tqchen
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] comaniac edited a comment on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
comaniac edited a comment on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-636633165
Hmm, docstring is a fair point. One solution I can think of is adding the API description in the docstring of the corresponding class. For example, adding “is_tuple” to the description of “TuplePattern”. I’ll think more tonight.
cc @tqchen in case you have any ideas.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] tqchen edited a comment on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
tqchen edited a comment on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-636961679
I agree that it is better to keep the docstring and add indirection in this case, as we did in many places in the codebase
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] tqchen commented on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-636961679
I agree that it is better to keep the docstring and add indirection in this case, as we did in many cases in the codebase
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] comaniac commented on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
comaniac commented on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-636971180
OK I'll change them back then.
@mbrookhart how about `is_input` vs. `is_var`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] comaniac edited a comment on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
comaniac edited a comment on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-637038571
Ah, this is a bit tricky. For type annotation, we should use `DFPattern` in this case. However, in Python 3.6, it evaluates the annotations at function definition time. It means if we define a class and refer it in the same file, the type checking won't find that class and will report type errors. While this issue has been fixed in Python 3.7, an official workaround is using a string for the class type. You can see https://stackoverflow.com/questions/15853469/putting-current-class-as-return-type-annotation for details.
Since TVM hasn't officially required Python 3.7+, I'd make sure the type annotation we are using is Python 3.6 compatible.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] mbrookhart commented on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
mbrookhart commented on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-636974410
:+1: I'm happy with that, it's more clear.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] mbrookhart commented on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
mbrookhart commented on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-636976223
Just to look at what this did to the API docs, I did a local build of the docs and realized I didn't get the pattern language into the API doc build :scream: @comaniac do you want to add that as part of this PR, or should I do another?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] comaniac commented on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
comaniac commented on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-637038571
Ah, this is a bit tricky. For type annotation, we should use `DFPattern` in this case. However, in Python 3.6, it parses the source file only once for type checking. It means if we define a class and refer it in the same file, the type checking won't find that class and will report type errors. While this issue has been fixed in Python 3.7, an official workaround is using a string for the class type. You can see https://stackoverflow.com/questions/15853469/putting-current-class-as-return-type-annotation for details.
Since TVM hasn't officially required Python 3.7+, I'd make sure the type annotation we are using is Python 3.6 compatible.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] mbrookhart commented on pull request #5703: [PatternLang] Simplify Pattern API Implementations
Posted by GitBox <gi...@apache.org>.
mbrookhart commented on pull request #5703:
URL: https://github.com/apache/incubator-tvm/pull/5703#issuecomment-636586492
I'm cool with the PR in general, but I'm a little skeptical of removing all of the doc strings for the syntactic sugar functions. Then again, I love the simplicity of it, so I'll think about it some more and give you some more feedback tomorrow morning.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org