-
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
[Relay] Remove memory planing from LowerTEPass #8974
Conversation
Add attrs to IRModule equal and hash Make LowerTEPass opt_level 0 Copy IRModule attrs to per_target_modules Add ShallowCopy to IRmodule
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.
One small nit but otherwise LGTM! Thanks :)
@@ -45,6 +45,13 @@ namespace tvm { | |||
namespace relay { | |||
namespace backend { | |||
|
|||
struct EnumClassHash { |
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.
Could you EnumClassHash into "utils.h" and remove this definition of it and the definition in the te compiler?
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.
done
I think this lgtm but will need to take another look once #8914 is in so the diff is clean. Thanks. |
@mikepapadim #8914 is merged. |
I ll have a look why CI is failing in this one now. |
|
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 @mikepapadim, overall I think the actual change makes sense but the PR touches a lot of unrelated files which will make the history more confused and it's difficult to understand the rationale behind the changes, such as introducing tec::
and changing relative imports to have ./
for this patch.
Would it be possible for you to scope this PR to just the changes that remove the memory planning?
transform::InferType(), | ||
tec::LowerTEPass(targets, device_map, memory_plan, /*module_name=*/"intrp", | ||
[](Function func) { /* no-op */ })}); | ||
transform::Sequential seq({transform::SimplifyInference(), |
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.
Seems we have inconsistent formatters? In any case I'd revert this whitespace change.
@@ -596,68 +596,19 @@ class LowerTensorExprMutator : public ExprMutator { | |||
const Op& debug_op_; | |||
}; | |||
|
|||
Pass LowerTensorExpr(TargetMap targets, DeviceMap device_context_map, |
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.
How about we don't move these to keep the diff down.
I'll confess I've been doing the same in my PRs and tend to clean up spelling mistakes and minor style glitches as I encounter them without factoring them out. Absolutely agree ideally they'd go in as 'no semantic change' PRs, but the CI delay and review overhead makes me much more forgiving. That said I left two suggestions to lower the diff. I've also been using "./foo.h" instead of "foo.h" to remind me of the abs imports, but maybe that's just my OCD. Note that the LowerTEPass call was resolving to tec::LowerTEPass only because the first argument is also in tec::, a fairly obscure C++ namespace trick, so I'd agree spelling those out is a Good Thing. @mikepapadim, can you prefix the title with [Relay] to follow convention. |
LGTM modulo comments. |
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, looks good to me! Just one comment about code clarity / structure :)
Also I second the thing about additional cleanups-- given CI time it takes a lot of time to pull these out.
Also @mikepapadim, FYI changing the title will retrigger CI!
if (memory_plan.defined()) { | ||
// TODO(@electriclilies, @jroesch): remove UpdateMainWorkspaceSize | ||
func_info = tec::UpdateMainWorkspaceSize(mod, targets_, memory_plan->expr_to_storage_info); | ||
} |
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.
Can you just put the func_info
on the mod here before passing the module into LowerTE? Then you don't need to re-extract it later, and also the logic surrounding func_info is all in one place. (LowerTEPass should preserve all attributes on modules passed into it)
Optional<backend::FunctionInfo> main_func_info = | ||
lowered_mod->GetAttr<backend::FunctionInfo>("main_func_info"); | ||
|
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.
Like I said above, can you attach the func_info right before LowerTEPass is called? And we can then remove the check about whether the attribute is on the module.
func_info = | ||
relay::tec::UpdateMainWorkspaceSize(mod, targets_, memory_plan_->expr_to_storage_info); | ||
} | ||
|
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.
Same comment as in aot_executor_codegen -- can we put the func_info on the module here instead of after LowerTEPass is called and delete the check for main_func_info being set?
Whilst I can appreciate the annoyance that CI brings, this PR introduces more changes in unrelated files than I'm comfortable with. Now that @mbs-octoml has articulated the Also this PR seems to have inadvertently reverted #8973? I'd propose integrating @mbs-octoml's comments and then scoping the commit to just |
Thanks for the feedback. I think now is good to go. |
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 @mikepapadim, thanks for minimising this, I have a few more nits on my side but could you address the comments from @mbs-octoml?
backend::FunctionInfo func_info; | ||
|
||
if (memory_plan.defined()) { | ||
// TODO(@electriclilies, @jroesch): remove UpdateMainWorkspaceSize | ||
func_info = tec::UpdateMainWorkspaceSize(mod, targets_, memory_plan->expr_to_storage_info); | ||
mod = WithAttr(mod, "main_func_info", func_info); | ||
} |
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.
Can we condense this to:
backend::FunctionInfo func_info; | |
if (memory_plan.defined()) { | |
// TODO(@electriclilies, @jroesch): remove UpdateMainWorkspaceSize | |
func_info = tec::UpdateMainWorkspaceSize(mod, targets_, memory_plan->expr_to_storage_info); | |
mod = WithAttr(mod, "main_func_info", func_info); | |
} | |
if (memory_plan.defined()) { | |
// TODO(@electriclilies, @jroesch): remove UpdateMainWorkspaceSize | |
backend::FunctionInfo func_info = tec::UpdateMainWorkspaceSize(mod, targets_, memory_plan->expr_to_storage_info); | |
mod = WithAttr(mod, "main_func_info", func_info); | |
} |
backend::FunctionInfo func_info; | ||
|
||
if (memory_plan_.defined()) { | ||
// TODO(@electriclilies, @jroesch): remove UpdateMainWorkspaceSize | ||
func_info = | ||
relay::tec::UpdateMainWorkspaceSize(mod, targets_, memory_plan_->expr_to_storage_info); | ||
mod = WithAttr(mod, "main_func_info", func_info); | ||
} | ||
|
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.
As above:
backend::FunctionInfo func_info; | |
if (memory_plan_.defined()) { | |
// TODO(@electriclilies, @jroesch): remove UpdateMainWorkspaceSize | |
func_info = | |
relay::tec::UpdateMainWorkspaceSize(mod, targets_, memory_plan_->expr_to_storage_info); | |
mod = WithAttr(mod, "main_func_info", func_info); | |
} | |
if (memory_plan_.defined()) { | |
// TODO(@electriclilies, @jroesch): remove UpdateMainWorkspaceSize | |
backend::FunctionInfo func_info = | |
relay::tec::UpdateMainWorkspaceSize(mod, targets_, memory_plan_->expr_to_storage_info); | |
mod = WithAttr(mod, "main_func_info", func_info); | |
} | |
@mikepapadim can you follow up on @Mousius's request in a follow up PR, going to land so we can keep the queue clean and should be easy to send small followup. |
* main: (102 commits) Implementation of relay_to_tir target hook (apache#8423) [Onnx] Fix NLL Loss tests (apache#8971) [Bugfix] Fix other div zero errors also in rewrite_simplify (apache#8983) [ONNX] enable the onnx tests after PR apache#8274 merged (apache#9019) [Hexagon] Disable `thread_local` on Hexagon (apache#9025) [Hexagon] Allow undefined symbols in libtvm_runtime.so on Hexagon (apache#9024) [Onnx] Add momentum (apache#9000) fix (apache#9021) [Community] @AndrewZhaoLuo -> Reviewer (apache#9020) [Hexagon] Implement model launcher (apache#8986) [Relay][Pass] Add ExtractOperators pass (apache#8996) [BYOC][TensorRT] Add TensorRT own int8 calibration support to TensorRT BYOC integration (apache#8808) [ONNX] Add Einsum converter (apache#8985) Add standalone_crt/ to be part of the wheel package, when available. (apache#9005) [Relay] Remove memory planing from LowerTEPass (apache#8974) [Hexagon] Treat floats as float32 when passing args to offloaded kernels (apache#9010) [Runtime] Pipeline Executor Initial patch. (apache#8702) [Hexagon] `llvm-options` attribute is an array of strings (apache#9011) disable cuda int8 schedule for non-cuda gpu target (apache#9014) [Torch] Add an option to make imported models compatible with the Relay text parser (apache#9015) ...
* Clean up LowerTEPass Add attrs to IRModule equal and hash Make LowerTEPass opt_level 0 Copy IRModule attrs to per_target_modules Add ShallowCopy to IRmodule * Fix rebase * Remove comment * [TEC] Remove memory plan from LowerTEPass * Fix linting errors * Fix PR comments * Remove updated module with function info from LowerTe * Refactor UpdateMainWorkspaceSize to update func info independently from LowerTEPass * Fix aot failed tests * Revert whitespaces fixes * Remove obsolete function hoisting and minor cleanups * Address PR comments Co-authored-by: electriclilies <lilyorthsmith@gmail.com>
* Clean up LowerTEPass Add attrs to IRModule equal and hash Make LowerTEPass opt_level 0 Copy IRModule attrs to per_target_modules Add ShallowCopy to IRmodule * Fix rebase * Remove comment * [TEC] Remove memory plan from LowerTEPass * Fix linting errors * Fix PR comments * Remove updated module with function info from LowerTe * Refactor UpdateMainWorkspaceSize to update func info independently from LowerTEPass * Fix aot failed tests * Revert whitespaces fixes * Remove obsolete function hoisting and minor cleanups * Address PR comments Co-authored-by: electriclilies <lilyorthsmith@gmail.com>
This PR is on top of #8914 and removes the memory planing from
LowerTEPass
.@jroesch @electriclilies @mbs-octoml