Call the global variable. Parameters ---------- args: List[RelaxExpr] The arguments to the call. Returns ------- call: BaseExpr A call taking the variable as a function.
(self, *args: RelaxExpr)
| 81 | self.__init_handle_by_constructor__(_ffi_api.GlobalVar, name_hint) |
| 82 | |
| 83 | def __call__(self, *args: RelaxExpr) -> BaseExpr: |
| 84 | """Call the global variable. |
| 85 | |
| 86 | Parameters |
| 87 | ---------- |
| 88 | args: List[RelaxExpr] |
| 89 | The arguments to the call. |
| 90 | |
| 91 | Returns |
| 92 | ------- |
| 93 | call: BaseExpr |
| 94 | A call taking the variable as a function. |
| 95 | """ |
| 96 | # pylint: disable=import-outside-toplevel |
| 97 | |
| 98 | # TODO(@relax-team): replace with Relax base class after it's introduced |
| 99 | if all(isinstance(x, RelaxExpr) for x in args): |
| 100 | from tvm import relax |
| 101 | |
| 102 | return relax.Call(self, args) |
| 103 | |
| 104 | elif all(isinstance(x, Number | PrimExpr) for x in args): |
| 105 | return tvm.tirx.call_tir(self, *args) |
| 106 | |
| 107 | arg_types = [type(x) for x in args] |
| 108 | raise RuntimeError(f"Do not know how to handle GlobalVar.__call__ for types {arg_types}") |
| 109 | |
| 110 | |
| 111 | @tvm_ffi.register_object("ir.Range") |