MCPcopy Index your code
hub / github.com/apache/tvm / visit_tvm_declare_function

Function visit_tvm_declare_function

python/tvm/relax/script/parser/parser.py:268–288  ·  view source on GitHub ↗
(self: Parser, node: doc.FunctionDef)

Source from the content-addressed store, hash-verified

266
267@dispatch.register(token="relax", type_name="tvm_declare_function")
268def 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")

Callers

nothing calls this directly

Calls 7

eval_struct_infoFunction · 0.85
with_frameMethod · 0.80
report_errorMethod · 0.80
create_emptyMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…