junrushao commented on code in PR #15670:
URL: https://github.com/apache/tvm/pull/15670#discussion_r1319170529
##########
python/tvm/relax/frontend/nn/spec.py:
##########
@@ -105,17 +126,28 @@ def from_raw(spec: MethodSpecType, method: Callable) ->
"MethodSpec":
method_signature = inspect.signature(method)
arg_names = list(method_signature.parameters.keys())
arg_specs = []
+
+ def _convert_arg_spec(arg_spec, arg_name):
+ if arg_spec is Int or arg_spec is int:
+ return Int()
+ elif isinstance(arg_spec, str) and arg_spec == "int":
+ return Int()
+ elif isinstance(arg_spec, (Int, Tensor)):
+ return arg_spec
+ elif isinstance(arg_spec, (tuple, list, Tuple)):
+ return type(arg_spec)(
+ [
+ _convert_arg_spec(arg_spec_i, f"{arg_name}_{i}")
+ for i, arg_spec_i in enumerate(arg_spec)
+ ]
+ )
Review Comment:
```suggestion
return Tuple(arg_spec, ...)(
[
_convert_arg_spec(arg_spec_i, f"{arg_name}_{i}")
for i, arg_spec_i in enumerate(arg_spec)
]
)
```
--
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]