-
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
[Unity] Introduce call_dps_packed #14183
Conversation
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
Do we have any way to enforce that the function passed to |
We can enforce it in |
It would have to be in the implementation as well, since you can do something like assign a TIR function to a local var and pass that local var elsewhere. In a higher-order function, we wouldn't be able to detect that at compile time unless we make TIR functions part of the type system (though that could be an option). |
We can have wellformess to enforce such invariant |
please run the following commend to update to latest change
|
It would not always be possible to check statically that the operand to @R.function
def higher_order(f: R.Object) -> R.Object:
return R.call_tir(f, ...)
@R.function
def g() -> R.Object:
if some_condition:
y = some_packed_func
else:
y = some_primfunc
return higher_order(y) We would not be able to determine statically that the call to Edit: Otherwise, we could ask for only global vars to be the arguments to |
Have updated well-form check to just allow GlobalVar as the first argument of call_tir. Actually current inline PrimFunc was disallowed in Relax IR, |
Yes, the RHS of that assignment would have to be a global var; we do not permit inline PrimFunc definitions. Perhaps we should get wider agreement if we want to have a restriction of using only global vars for |
Co-authored-by: Steven S. Lyubomirsky <[email protected]>
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.
My concerns have been addressed and everything seems to be reasonable.
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.
Overall LGTM! Thanks!
Just some minor nits which can be handled in follow up PRs
legalize_ops would throw a warning for call_dps_packed: https://github.com/psrivas2/tvm/blob/emit-te/src/relax/transform/legalize_ops.cc#L105
Would there be follow up PRs for cleaning up transform/backend passes which earlier checked if call_tir is calling an extern func such as
- https://github.com/psrivas2/tvm/blob/emit-te/src/relax/backend/task_extraction.cc#L77
- https://github.com/psrivas2/tvm/blob/emit-te/src/relax/transform/fold_constant.cc#L181
- https://github.com/psrivas2/tvm/blob/emit-te/src/relax/transform/fuse_ops.cc#L188
- https://github.com/psrivas2/tvm/blob/emit-te/src/relax/transform/fuse_tir.cc#L305
- https://github.com/psrivas2/tvm/blob/emit-te/src/relax/transform/rewrite_dataflow_reshape.cc#L78
@@ -33,7 +33,7 @@ namespace relax { | |||
|
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.
nit: should we rename this file and pass to reflect that it handles both call_dps_packed and call_tir?
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 was thinking about this, but don't have a better name, any suggestions? if we change this, then the pass name CallTIRRewrite needs to be updated accordingly. We can keep it untouched for now if we don't have an alternative names,
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.
DPSRewrite would be my choice but we can discuss and change it later.
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 suggestion! We can discuss it later, it might need to get wider agreement for pass renaming.
Have updated for all passes, thanks a lot for pointing them out!!! |
Introduce call_dps_packed to call packed functions in destination-passing style, reserving call_tir for TIR PrimFuncs instead. * [Unity] Introduce call_dps_packed * fix lint * Fix comments * Remove well_form update, enforce in InferStructInfoCallTIR * Update src/relax/op/op.cc * Update description of call_tir * Remove unnecessary check in passes
Introduce call_dps_packed to call packed functions in destination-passing style, reserving call_tir for TIR PrimFuncs instead. * [Unity] Introduce call_dps_packed * fix lint * Fix comments * Remove well_form update, enforce in InferStructInfoCallTIR * Update src/relax/op/op.cc * Update description of call_tir * Remove unnecessary check in passes
Introduce call_dps_packed to call packed functions in destination-passing style, reserving call_tir for TIR PrimFuncs instead. * [Unity] Introduce call_dps_packed * fix lint * Fix comments * Remove well_form update, enforce in InferStructInfoCallTIR * Update src/relax/op/op.cc * Update description of call_tir * Remove unnecessary check in passes
Introduce call_dps_packed to call packed functions in destination-passing style, reserving call_tir for TIR PrimFuncs instead. * [Unity] Introduce call_dps_packed * fix lint * Fix comments * Remove well_form update, enforce in InferStructInfoCallTIR * Update src/relax/op/op.cc * Update description of call_tir * Remove unnecessary check in passes
Introduce call_dps_packed to call packed functions in destination-passing style, reserving call_tir for TIR PrimFuncs instead. * [Unity] Introduce call_dps_packed * fix lint * Fix comments * Remove well_form update, enforce in InferStructInfoCallTIR * Update src/relax/op/op.cc * Update description of call_tir * Remove unnecessary check in passes
Introduce call_dps_packed to call packed functions in destination-passing style, reserving call_tir for TIR PrimFuncs instead. * [Unity] Introduce call_dps_packed * fix lint * Fix comments * Remove well_form update, enforce in InferStructInfoCallTIR * Update src/relax/op/op.cc * Update description of call_tir * Remove unnecessary check in passes
Introduce call_dps_packed to call packed functions in destination-passing style, reserving call_tir for TIR PrimFuncs instead. * [Unity] Introduce call_dps_packed * fix lint * Fix comments * Remove well_form update, enforce in InferStructInfoCallTIR * Update src/relax/op/op.cc * Update description of call_tir * Remove unnecessary check in passes
Introduce call_dps_packed to call packed functions in destination-passing style, reserving call_tir for TIR PrimFuncs instead. * [Unity] Introduce call_dps_packed * fix lint * Fix comments * Remove well_form update, enforce in InferStructInfoCallTIR * Update src/relax/op/op.cc * Update description of call_tir * Remove unnecessary check in passes
Introduce call_dps_packed to call packed function instead tir via destination passing convention