-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[tvm4j] register user-defined function #251
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
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.
If it is important to move ownership to the java side before you return, see https://github.com/dmlc/tvm/blob/master/include/tvm/runtime/c_runtime_api.h#L269
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.
before you pass the arguments to the callback function, since callback funtion might want to retain the value
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.
Very likely you can reuse the same logic of implementing call in the front-end, since that is simply call into Return
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.
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.
There is one possible bug I think I find today, since resource won't be constructed until user call asModule.
If user call asModule twice, there will be double free. If user won;t call asModule in return value. There will be memory leak
|
@tqchen It is ready for review. |
| * @param override Whether override existing entry. | ||
| */ | ||
| public static void register(String name, Callback function, boolean override) { | ||
| int fid = genFunctionId(function); |
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.
Directly use jobject as handle as in https://github.com/dmlc/xgboost/blob/master/jvm-packages/xgboost4j/src/native/xgboost4j.cpp
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.
| } | ||
|
|
||
| @Test | ||
| public void test_reg_sum_ndarray() { |
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.
To increase coverage, I would recommend to add the test that takes function as argument and returns a function
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.
This PR features `match_shape` support, which contains: - MatchShape support for both var emitting and non-emitting cases - Allow TIR operators dtype broadcasting. (e.g. `i64 * i32`) Co-authored-by: Ruihang Lai <[email protected]>
[TVMScript] B4: If branch support (apache#263) B8: Local Function Support (apache#258) [TVMScript] B3: Type annotation checks (apache#256) [TVMScript][Parser] B1: Dataflow block (apache#252) [TVMScript] B2: match shape support (apache#251) [TVMScript] B6/B7: Symbolic shape and var shadowing (apache#245) [TVMScript] B5: Support relax op (apache#244) [TVMScript] B0: Call_tir support (apache#243) enhance parser error reporting (apache#242) [TVMScript] A1: Relax Parser infra (apache#240) update ci image versions. (apache#241) [TVMScript] B2-4: TIR IRBuilder (apache#239) [TVMScript] A0: Relax IRBuilder infra (apache#235) [TVMScript] B5-6: TIR IRBuilder (apache#231) [TVMScript] B1: IRBuilder (apache#228) [TVMScript] New Parser: Part C (apache#218) [TVMScript] New Parser: Part A (apache#221) [TVMScript] New Parser: Part B (apache#217) Not recovered: [Pass] Separate ApplyHistoryBest from tuning passes (apache#226) [Bugfix] Couple of bug fixes to run TVM-gen code together with BYOC (apache#249) co-authored-by: Yuchen Jin <[email protected]> co-authored-by: Siyuan Feng <[email protected]> co-authored-by: Ruihang Lai <[email protected]>
[TVMScript] B4: If branch support (apache#263) B8: Local Function Support (apache#258) [TVMScript] B3: Type annotation checks (apache#256) [TVMScript][Parser] B1: Dataflow block (apache#252) [TVMScript] B2: match shape support (apache#251) [TVMScript] B6/B7: Symbolic shape and var shadowing (apache#245) [TVMScript] B5: Support relax op (apache#244) [TVMScript] B0: Call_tir support (apache#243) enhance parser error reporting (apache#242) [TVMScript] A1: Relax Parser infra (apache#240) update ci image versions. (apache#241) [TVMScript] B2-4: TIR IRBuilder (apache#239) [TVMScript] A0: Relax IRBuilder infra (apache#235) [TVMScript] B5-6: TIR IRBuilder (apache#231) [TVMScript] B1: IRBuilder (apache#228) [TVMScript] New Parser: Part C (apache#218) [TVMScript] New Parser: Part A (apache#221) [TVMScript] New Parser: Part B (apache#217) Not recovered: [Pass] Separate ApplyHistoryBest from tuning passes (apache#226) [Bugfix] Couple of bug fixes to run TVM-gen code together with BYOC (apache#249) co-authored-by: Yuchen Jin <[email protected]> co-authored-by: Siyuan Feng <[email protected]> co-authored-by: Ruihang Lai <[email protected]>
[TVMScript] B4: If branch support (apache#263) B8: Local Function Support (apache#258) [TVMScript] B3: Type annotation checks (apache#256) [TVMScript][Parser] B1: Dataflow block (apache#252) [TVMScript] B2: match shape support (apache#251) [TVMScript] B6/B7: Symbolic shape and var shadowing (apache#245) [TVMScript] B5: Support relax op (apache#244) [TVMScript] B0: Call_tir support (apache#243) enhance parser error reporting (apache#242) [TVMScript] A1: Relax Parser infra (apache#240) update ci image versions. (apache#241) [TVMScript] B2-4: TIR IRBuilder (apache#239) [TVMScript] A0: Relax IRBuilder infra (apache#235) [TVMScript] B5-6: TIR IRBuilder (apache#231) [TVMScript] B1: IRBuilder (apache#228) [TVMScript] New Parser: Part C (apache#218) [TVMScript] New Parser: Part A (apache#221) [TVMScript] New Parser: Part B (apache#217) Not recovered: [Pass] Separate ApplyHistoryBest from tuning passes (apache#226) [Bugfix] Couple of bug fixes to run TVM-gen code together with BYOC (apache#249) co-authored-by: Yuchen Jin <[email protected]> co-authored-by: Siyuan Feng <[email protected]> co-authored-by: Ruihang Lai <[email protected]>
[TVMScript] B4: If branch support (apache#263) B8: Local Function Support (apache#258) [TVMScript] B3: Type annotation checks (apache#256) [TVMScript][Parser] B1: Dataflow block (apache#252) [TVMScript] B2: match shape support (apache#251) [TVMScript] B6/B7: Symbolic shape and var shadowing (apache#245) [TVMScript] B5: Support relax op (apache#244) [TVMScript] B0: Call_tir support (apache#243) enhance parser error reporting (apache#242) [TVMScript] A1: Relax Parser infra (apache#240) update ci image versions. (apache#241) [TVMScript] B2-4: TIR IRBuilder (apache#239) [TVMScript] A0: Relax IRBuilder infra (apache#235) [TVMScript] B5-6: TIR IRBuilder (apache#231) [TVMScript] B1: IRBuilder (apache#228) [TVMScript] New Parser: Part C (apache#218) [TVMScript] New Parser: Part A (apache#221) [TVMScript] New Parser: Part B (apache#217) Not recovered: [Pass] Separate ApplyHistoryBest from tuning passes (apache#226) [Bugfix] Couple of bug fixes to run TVM-gen code together with BYOC (apache#249) co-authored-by: Yuchen Jin <[email protected]> co-authored-by: Siyuan Feng <[email protected]> co-authored-by: Ruihang Lai <[email protected]>
This PR supports the reshape PrimFunc detection analysis with iter-map-simplify, in order to better support TIR functions with dynamic variables, which is not well handled before. Meanwhie, this PR also keeps the existing analysis logic, so that we are still able to cover the cases like reshape with raggedness. Unit tests for reshape are added to ensure correctness.
* 1.79us Co-authored-by: Hongyi Jin <[email protected]> * 1.78us --------- Co-authored-by: Hongyi Jin <[email protected]>
It is not ready to merge, while
Function.main()works.TBD: