(self: Parser, node: doc.FunctionDef)
| 266 | |
| 267 | @dispatch.register(token="relax", type_name="tvm_declare_function") |
| 268 | def visit_tvm_declare_function(self: Parser, node: doc.FunctionDef) -> GlobalVar: |
| 269 | with self.var_table.with_frame(): |
| 270 | collect_symbolic_var_from_params(self, node) |
| 271 | |
| 272 | if node.returns is None: |
| 273 | # Use ObjectStructInfo as unknown return type |
| 274 | # NOTE: Cannot use VoidStructInfo here because the return type can be refined later. |
| 275 | ret_sinfo = relax.ObjectStructInfo() |
| 276 | else: |
| 277 | ret_sinfo = eval_struct_info(self, node.returns, eval_str=True) |
| 278 | params = [] |
| 279 | for arg in node.args.args: |
| 280 | if arg.annotation is None: |
| 281 | self.report_error(arg, "Type annotation is required for function parameters.") |
| 282 | param_sinfo = eval_struct_info(self, arg.annotation, eval_str=True) |
| 283 | params.append(relax.Var(arg.arg, param_sinfo)) |
| 284 | |
| 285 | is_pure = find_decorator_annotation(node, "pure") |
| 286 | |
| 287 | func_signature = relax.Function.create_empty(params, ret_sinfo, is_pure=is_pure) |
| 288 | return I.decl_function(node.name, func_signature) |
| 289 | |
| 290 | |
| 291 | @dispatch.register(token="relax", type_name="pre_visit_local_function") |
nothing calls this directly
no test coverage detected
searching dependent graphs…