From 634f92fe85f33fa44df725c560d71aab95e76513 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Mon, 26 Jun 2023 13:09:51 +0800 Subject: [PATCH] fix(mge/tm): remove annotations in argspec for tm compatibility GitOrigin-RevId: 9d49077e458aa367fd76dadc93b6318bc9b7f954 --- imperative/python/megengine/traced_module/traced_module.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/imperative/python/megengine/traced_module/traced_module.py b/imperative/python/megengine/traced_module/traced_module.py index 0f156d18b..6cbf9ebb2 100644 --- a/imperative/python/megengine/traced_module/traced_module.py +++ b/imperative/python/megengine/traced_module/traced_module.py @@ -2474,6 +2474,12 @@ def trace_module( if hasattr(mod, "argspec") else inspect.getfullargspec(mod.forward) ) + if isinstance(forward_argspec, inspect.FullArgSpec): + argspec_dict = forward_argspec._asdict() + # check defaults + tree_flatten((forward_argspec.defaults, forward_argspec.kwonlydefaults)) + argspec_dict["annotations"] = {} + forward_argspec = inspect.FullArgSpec(**argspec_dict) args, kwargs = _convert_kwargs_to_args(forward_argspec, args, kwargs, True) inputs, _ = tree_flatten((args, kwargs)) for _, i in enumerate(inputs): -- GitLab