Skip to content
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

[CORE][Relay] Swap and remove compile_engine with te_compiler followup of #8775 #9282

Merged
merged 20 commits into from
Oct 22, 2021

Conversation

mikepapadim
Copy link
Contributor

This is a follow-up work for #8775 to address the pending comments to remove the compile_engine.

As this is an intermediate step towards completely moving away from the engine, we exposed the following legacy functions from the compile engine to ensure backwards compatibility atm:

  • _TECompilerJIT
  • _TECompilerLower
  • _make_LoweredOutput
  • _make_CCacheKey

Now, compile_engine.py has been replaced with te_compiler.py and deprecated funcs, such as LowerShapeFuncs kept private within the te_compiler.cc.

@jroesch @mbs-octoml @electriclilies @comaniac @junrushao1994

@mikepapadim mikepapadim requested a review from Hzfengsy as a code owner October 15, 2021 09:32
try:
mod_name = mangle_module_name(mod_name)
key = _get_cache_key(source_func, target)
print(key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A stray print!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

ret.append(dim)
return ret


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this replaced with?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, now I see this was just moved. Nevermind

"""
# pylint: disable=broad-except, import-outside-toplevel
try:
mod_name = mangle_module_name(mod_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do name mangling here instead of in TECompilerLower?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is directly taken from the original compile_engine. I agree we can move it to C++ through te_compiler, but I see a few other usages of it within the codebase.

@electriclilies
Copy link
Contributor

Overall, LGTM, I just have a few nitpicks. I took a quick look at what is failing and it looks like there are some issues with the registration, but once those are resolved this looks like it is good to go in! Thanks!

@mikepapadim
Copy link
Contributor Author

PTAL @mbs-octoml @jroesch @electriclilies

Copy link
Member

@Mousius Mousius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly this looks good, just found a few bits to tidy

python/tvm/relay/backend/te_compiler.py Outdated Show resolved Hide resolved
tests/python/contrib/test_vitis_ai/infrastructure.py Outdated Show resolved Hide resolved
@@ -721,7 +723,7 @@ def compile_and_run(

def generate_ref_data(mod, input_data, params=None, target="llvm"):
"""Generate reference data through executing the relay module"""
compile_engine.get().clear()
te_compiler.get().clear()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need this anymore for AOT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, i think is not required anymore. It was transilient from compile engine.

@mikepapadim
Copy link
Contributor Author

Mostly this looks good, just found a few bits to tidy

Thanks, just pushed the fixes.

Copy link
Contributor

@mbs-octoml mbs-octoml left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thank you Michalis.

@@ -142,7 +142,7 @@ def _traverse_expr(node):
params.append(free_var)
call = relay.Call(node.op, params, node.attrs)
mod = tvm.IRModule.from_expr(relay.Function(params, call))
relay.backend.compile_engine.get().clear()
relay.backend.te_compiler.get().clear()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize there were so many uses of the dreaded global. Could you please file a JIRA issue to remove them? I suspect simply creating locally would be fine and this has been done just for 'efficiency'. If not we have bigger problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just filled a ticket on it. I did locally for a few test with no issues. So, after this on is merged. I can sent a followup PR unifying all usages.

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
@icemelon please also take a look, as this may affect our use cases.

Copy link
Contributor

@electriclilies electriclilies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks so much!

@jroesch
Copy link
Member

jroesch commented Oct 19, 2021

I will wait some time for Haichen before merging.

@mikepapadim
Copy link
Contributor Author

I will wait some time for Haichen before merging.

Thanks! We can do some followups as @mbs-octoml suggested.

@mikepapadim
Copy link
Contributor Author

@jroesch should we merge this one?

@masahi masahi merged commit 6ef1c2a into apache:main Oct 22, 2021
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 7, 2022
…p of apache#8775 (apache#9282)

* Remove compile_engine.h for real

* Fix format

* RM compile_engine.cc

* Swap compile engine with TECompiler

* Cleanup on compile engine py leftovers

* [WIP] Exposing legacy compile engine capabilities through TE Compiler

* Swap usages for depreciated compile engine with TE compiler

* Track and replace usages of compile engine refactor them to TE compiler

* [Docs] Log helper mod

* Remove depreciated function for lookup compile engine cachce

* Fix typos

* Debug misc cleanups

* Register global pass for using te compiler for auto scheduler

* Fix tests using the legacy compile engine

* Fix broken autotuner tests and minor cleanups

* Swap compile engine with te_compiler in rst config

* PR nits

* Fix failed test

Co-authored-by: Jared Roesch <[email protected]>
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
…p of apache#8775 (apache#9282)

* Remove compile_engine.h for real

* Fix format

* RM compile_engine.cc

* Swap compile engine with TECompiler

* Cleanup on compile engine py leftovers

* [WIP] Exposing legacy compile engine capabilities through TE Compiler

* Swap usages for depreciated compile engine with TE compiler

* Track and replace usages of compile engine refactor them to TE compiler

* [Docs] Log helper mod

* Remove depreciated function for lookup compile engine cachce

* Fix typos

* Debug misc cleanups

* Register global pass for using te compiler for auto scheduler

* Fix tests using the legacy compile engine

* Fix broken autotuner tests and minor cleanups

* Swap compile engine with te_compiler in rst config

* PR nits

* Fix failed test

Co-authored-by: Jared Roesch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants