synr icon indicating copy to clipboard operation
synr copied to clipboard

Call for ifExp supporting

Open ShouyangDong opened this issue 4 years ago • 3 comments

Right now I am working on the parser of tvm.tir.script, but a minor question that I met is about tvm.tir.Select. This function is related to IfExp node. When will be IfExp node supported in synr? Thank you.

ShouyangDong avatar Sep 27 '21 03:09 ShouyangDong

Hey thanks for asking! I believe tir.Select is a bit different from tir.IfThenElse in terms of semantics. @Hzfengsy would you like to confirm?

To make sure I understand this question, are you asking if it is possible to translate python's XXX if CCC else YYY expression to tir.IfThenElse?

junrushao avatar Sep 27 '21 17:09 junrushao

IfThenElseNode is a stmt with two sub-stmt then_case and else_case, it equals to

if condition:
    then_case
else:
    else_case

tir.Select is an expr with true_value and false_value, which equals to

true_value if condition else false_value

IIRC, it is not supported by now. I can support it when I have time.

Hzfengsy avatar Sep 28 '21 01:09 Hzfengsy

Thank you @junrushao1994 and @Hzfengsy. true_value if condition else false_value is quite important when I process these control flow of Scalars. By the way, do you have any plan to support cross function calls? I take the code snippet below for example,

def A():
   return 0

def main():
     a  = A ()

That will be quite useful when we implement these long tail operators like nms and region_proposal, etc. Thank you very much!

ShouyangDong avatar Sep 28 '21 02:09 ShouyangDong