MCPcopy Create free account
hub / github.com/pytorch/executorch / extract_init_args_from_instance

Function extract_init_args_from_instance

examples/qualcomm/utils.py:54–70  ·  view source on GitHub ↗
(instance)

Source from the content-addressed store, hash-verified

52 """
53
54 def extract_init_args_from_instance(instance):
55 init_signature = inspect.signature(instance.__init__)
56 init_params = [
57 param
58 for param in init_signature.parameters.values()
59 if param.name != "self"
60 ]
61
62 extracted_args = {}
63 for param in init_params:
64 name = param.name
65 if hasattr(instance, name):
66 extracted_args[name] = getattr(instance, name)
67 elif param.default is not inspect.Parameter.empty:
68 extracted_args[name] = param.default
69
70 return extracted_args
71
72 if extra_custom_kwargs is None:
73 extra_custom_kwargs = {}

Callers 1

Calls 1

valuesMethod · 0.80

Tested by

no test coverage detected