-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[RUNTIME] Implement TVMDSOOp(TensorFlow custom op) for TVM runtime #4459
Conversation
It would be great if @tqchen would help to review this. |
@tobegit3hub please fix the lint error. @soiferj @jwfromm @zhiics @FrozenGene would be great if you can help review this pr |
Sure. I will do a pass by tomorrow. |
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.
I am half way done. Will spend some time on the remaining files. Some high level comments/questions are:
- Style, please make sure you keep consistent to the currently code style in TVM. For example, indentation for Python and C++, number of blank lines between functions, etc.
- Naming, we might need to debate a bit about
TVMDSOOp
- Testing, please add some unit tests. I think we need both Python tests and gtest.
- I've finished reviewing, but I am wondering how dynamic shape is handled?
Thanks @FrozenGene and @zhiics . We will fix for these comments soon. Since TensorFlow allow custom operators to accept dynamic shape whose first dimension is -1, we can get the actual input dimension from input tensor in kernel compute function. The output dimension should be specified by users. Now we support specifying the fixed dimension or pass the shape op which is the transformation of input tensor. |
feat: Update tf tvmdso op by review comments See merge request internal-open-source/incubator-tvm!2
fix: Update with pr comments See merge request internal-open-source/incubator-tvm!3
fix: Fix lint See merge request internal-open-source/incubator-tvm!4
Hi @zhiics and @FrozenGene , we have updated the code for the comments. Would you like to review again when you are free? |
I think @gmagogsfm had a concern about the variable number of inputs/outputs, has this been fixed? |
Oh I miss it. @gmagogsfm remind a nice mechanism in TF to handle variable number of input tensors which will greatly simplify the current op definitions. I tend to make it in next PR, because currently we rely on template argument |
@wrongtest Let me know if you have other questions, happy to help. |
79a5fa3
to
3984459
Compare
3984459
to
9343669
Compare
Thanks for your help! We update the code and now there is no need to define different op for different input args. @gmagogsfm |
I will do a final round review in the next couple of days. I think overall it looks good to me now. @tqchen can you also 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.
Thanks for the effort. LGTM. Let's follow up in separate PRs and see how we can enable the tests to help ppl to try it out.
I will review it one round today. If no other comment, I will approve today. |
Wish we have one doc / tutorial to instruct users how to use this feature in the next pr. |
Thanks @tobegit3hub @FrozenGene @zhiics @soiferj @wrongtest @gmagogsfm @yzhliu . This PR is now merged |
…pache#4459) * Add implementation of TVMDSOOp * feat: Update cmake script to work with c++11 and in-repo build * feat: Use libtvm as oplib dependency * fix: Add missing link dependency to libtvm * feat: Update tf tvmdso op by review comments * fix: Update with pr comments * fix: Fix lint * feat: Add test script and fix gpu shape * feat: Add test script and fix gpu shape * fix: Conditional build tftvm op for gpu * fix: Conditional build tftvm op for gpu * fix: Fix pylint of tf_op module.py * fix: Fix pylint of tf_op module.py * feat: Conditional enable gpu test for tftvm op * feat: Conditional enable gpu test for tftvm op * feat: Add tf_tvmdsoop test script as an app test * fix: Fix gpu/cpu enabled check on tvm in test script * fix: Make tf tvmdso op test script runnable with pytest * remove unused test script test_tfop_module.py * fix: Remove pushd & popd in tfdsoop test script * fix: Upgrade tftvmop use python3 to find TensorFlow * fix: Upgrade tftvmop use python3 to find TensorFlow * fix: Change target_link_options to target_link_libraries * fix: Add tftvmop build script's c++ option * fix: Add tvm library path to tf op test library path * fix: Debug ci build for tftvm dso op * fix: Fix cmake error and skip tfop test * fix: Fix typo and indentation issues * feat: Use TF list input op def * fix: Fix style and unexpected changes Co-authored-by: baoxinqi <baoxinqi@4paradigm.com> Co-authored-by: Chen Dihao <chendihao@4paradigm.com> Co-authored-by: wrongtest <wrongtest@4paradigm.com>
…pache#4459) * Add implementation of TVMDSOOp * feat: Update cmake script to work with c++11 and in-repo build * feat: Use libtvm as oplib dependency * fix: Add missing link dependency to libtvm * feat: Update tf tvmdso op by review comments * fix: Update with pr comments * fix: Fix lint * feat: Add test script and fix gpu shape * feat: Add test script and fix gpu shape * fix: Conditional build tftvm op for gpu * fix: Conditional build tftvm op for gpu * fix: Fix pylint of tf_op module.py * fix: Fix pylint of tf_op module.py * feat: Conditional enable gpu test for tftvm op * feat: Conditional enable gpu test for tftvm op * feat: Add tf_tvmdsoop test script as an app test * fix: Fix gpu/cpu enabled check on tvm in test script * fix: Make tf tvmdso op test script runnable with pytest * remove unused test script test_tfop_module.py * fix: Remove pushd & popd in tfdsoop test script * fix: Upgrade tftvmop use python3 to find TensorFlow * fix: Upgrade tftvmop use python3 to find TensorFlow * fix: Change target_link_options to target_link_libraries * fix: Add tftvmop build script's c++ option * fix: Add tvm library path to tf op test library path * fix: Debug ci build for tftvm dso op * fix: Fix cmake error and skip tfop test * fix: Fix typo and indentation issues * feat: Use TF list input op def * fix: Fix style and unexpected changes Co-authored-by: baoxinqi <baoxinqi@4paradigm.com> Co-authored-by: Chen Dihao <chendihao@4paradigm.com> Co-authored-by: wrongtest <wrongtest@4paradigm.com>
…pache#4459) * Add implementation of TVMDSOOp * feat: Update cmake script to work with c++11 and in-repo build * feat: Use libtvm as oplib dependency * fix: Add missing link dependency to libtvm * feat: Update tf tvmdso op by review comments * fix: Update with pr comments * fix: Fix lint * feat: Add test script and fix gpu shape * feat: Add test script and fix gpu shape * fix: Conditional build tftvm op for gpu * fix: Conditional build tftvm op for gpu * fix: Fix pylint of tf_op module.py * fix: Fix pylint of tf_op module.py * feat: Conditional enable gpu test for tftvm op * feat: Conditional enable gpu test for tftvm op * feat: Add tf_tvmdsoop test script as an app test * fix: Fix gpu/cpu enabled check on tvm in test script * fix: Make tf tvmdso op test script runnable with pytest * remove unused test script test_tfop_module.py * fix: Remove pushd & popd in tfdsoop test script * fix: Upgrade tftvmop use python3 to find TensorFlow * fix: Upgrade tftvmop use python3 to find TensorFlow * fix: Change target_link_options to target_link_libraries * fix: Add tftvmop build script's c++ option * fix: Add tvm library path to tf op test library path * fix: Debug ci build for tftvm dso op * fix: Fix cmake error and skip tfop test * fix: Fix typo and indentation issues * feat: Use TF list input op def * fix: Fix style and unexpected changes Co-authored-by: baoxinqi <baoxinqi@4paradigm.com> Co-authored-by: Chen Dihao <chendihao@4paradigm.com> Co-authored-by: wrongtest <wrongtest@4paradigm.com>
RFC: #4464 .
This PR contains three parts to achieve the goal to run TVM op in TensorFlow.
tvm.contrib
to loadTVMDSOOp
easily.TVMDSOOp
easily.