yongwww commented on PR #14183: URL: https://github.com/apache/tvm/pull/14183#issuecomment-1458996643
> It would not always be possible to check statically that the operand to `call_tir` is a `PrimFunc`. Here is a case where it wouldn't work: > > ```python > @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 `higher_order` in `g` will result in a non-`PrimFunc` being passed to `call_tir`. If we care about enforcing the distinction, we would have to check for such cases dynamically. > > Edit: Otherwise, we could ask for only global vars to be the arguments to `call_tir`, which I don't think would be the worst thing in the world, but this limits the extent to which `PrimFunc`s and `PackedFunc`s are first class. (I don't think they really need to be first class, but in past discussions, we've said that that was desirable.) Have updated to well-form check to just allow GlobalVar as the first argument of call_tir. Actually current inline PrimFunc was disallowed in Relax IR, `y = some_primfunc` in the example has to be `y = global_var_of_some_primfunc`. I guess we won't run into issues at this moment, correct me if i am wrong -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
