[TIR] Tir constants integration into compilation pipeline#8509
[TIR] Tir constants integration into compilation pipeline#8509manupak merged 26 commits intoapache:mainfrom
Conversation
5f1da9c to
50d6052
Compare
Oh. not sure how did I manage to do this. I am sorry for such a massive query. |
fc4e057 to
64e0c42
Compare
64e0c42 to
a4d809e
Compare
a4d809e to
0665a8c
Compare
manupak
left a comment
There was a problem hiding this comment.
@d-smirnov , shall we look to update the design as agreed here ? : https://github.com/apache/tvm-rfcs/blob/main/rfcs/0022-tir-non-scalar-constants.md
0665a8c to
6c88c9d
Compare
Change-Id: Ia4adca9d3315b26fbdc006ef7c115900c081e303
Change-Id: Ice305f4fefd13fe95e97574e6d63ffeb664621df
Refactored ExtractPrimFuncConstants to IRModule pass. deDup -> DeDup Refactored logic of Applicator supplementary class Change-Id: I6c120d175eb6790ba90f176c4f856bde8f0c7c94
Change-Id: Ie3ee6ea2479476a30f486baef74f20070f117942
Change-Id: I12c63731663b9c9ea574b9ed5cb17311ba3cf701
|
Thanks @d-smirnov working so long on this to enable representation of non-scalar constants in TIR. Thanks @giuseros for the initial work.. |
|
We're seeing issues on Hexagon after this commit. They are directly caused by float16 not being supported for embedded constants, but there are other potential problems there (difference between target and executor in fuse_ops). See https://discuss.tvm.apache.org/t/problem-with-fuseops-and-embedded-constants-in-tir/12165 for more info. I'm wondering about your thoughts about this. |
|
@kparzysz-quic thanks for signaling the regression. Is there a way this problem can be triggered via a simple unit test? Perhaps we can get the authors to issue a patch, or perhaps even we could consider reverting this commit until we can resolve the issue? |
|
We can look into this. @kparzysz-quic , would you be able to submit a PR with an xfail that should have been broken by this PR ?
tvm/src/target/llvm/codegen_params.cc Lines 137 to 157 in dcbdedd tvm/src/target/source/codegen_params.cc Lines 214 to 229 in dcbdedd The above are called respectively in the following locations : tvm/src/target/llvm/codegen_llvm.cc Line 1485 in dcbdedd tvm/src/target/source/codegen_c.cc Line 673 in dcbdedd (These are same code used to codegen LinkedParam node) So, I am not following what is meant here.. Can you elaborate further ? To understand a bit more, would you be able to share the relay.build(...) configuration (targets, executor, runtime) that you are using ? Ideally, if the target does not support -link-params, it should be able to disable it or if the target needs them linked (i.e. not handled via executor) it needs codegen tir.AllocateConst node -- for which the support has been added for all backends of TVM (with tests). By naive, look at the Hexagon codegen it seems like it is extending codegen LLVM. So what we need to understand, what is the expectation of Hexagon backend when linked-param is used ? I am sensing we might need to move link-param from being executor attr to a target attr . cc : @Mousius @d-smirnov Im a bit concerned by the suggestion to revert based on non-tree tests. FYI : @u99127 |
|
We have a temporary workaround---just reset the There are two issues that need to be addressed:
Hexagon does utilize the |
|
Hi @kparzysz-quic , This PR is about non-scalar constants, 2) links to scalar constants -- maybe that feature is yet to be supported anyway ? For 1) maybe lets create an issue -- Im trying to understand the relevance to this PR, @d-smirnov thoughts ? |
|
Right---the relevance is that I tried setting "relay.FuseOps.link_params" to False in PassContext/config, but it didn't have any effect, since |
|
The changes in fuse_ops that this PR made (obtaining the value of |
I am still a bit puzzled. I read the above code as PassContext overriding whatever provided by the Executor. |
|
Would you be able to provide what should be the "correct" behaviour ? |
Line 1054: If executor is present in IRModule, set Line 1057: If the current config has a key "relay.FuseOps.link_params", set |
|
I think you mentioned that |
|
Hmmm, Just to understand this a bit better, what is the target string being used in your case ? Secondly, does the hexagon backend requires the constants binded to the IR, eventually to be codegen'd or does it require them to be provided at the runtime ? |
|
The first failing testcase is resnet50: This is the script that reproduces the crash is: At the bottom of the crash dump you should see The target string is We don't yet have codegen for Edit: This will crash with the upstream code as well, so if you have the same resnet50 as we do, you should be able to reproduce this crash. |
tvm/tests/python/relay/test_pass_fuse_ops.py Lines 631 to 661 in d9fac4f I think this is respected. maybe we should need to verify when Executor has link-params ? But after having read this all again -- the actual issue link-params will be set to True if the Executor has it. It seems like hexagon backend was reliant on FoldConstant behaviour of always having link-params set to False. Is it not ? If so the solution might be to provide link-params override for FoldConstants as well ? Something feels like link-params behaviour for FuseOps pass in the main compilation pipeline needs to be True. Am I wrong here ? |
|
Can ? / should this discussion please be moved into a proper issue ? Ramana |
|
Yes I think it make sense -- @kparzysz-quic lets create an issue and move it there. |
|
@manupa-arm and @junrushao1994 can you tag me on changes to CI scripts in the future? The changes here in |
|
Oops sorry about this! Will do |
|
thanks! btw, it's fixed in #10469 so no action here is necessary |
This PR is a follow-up PR to integate tir constant nodes introduced in 8472 to compilation pipeline.