MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / make_invocable_impl

Function make_invocable_impl

tools/Polygraphy/polygraphy/tools/script.py:99–121  ·  view source on GitHub ↗

Generates a string that would invoke the type specified in type_str with the specified arguments. Skips keyword arguments that are set to ``None``. For example: :: >>> make_invocable_impl("Example", None, "string", w=None, x=2, y=inline("test")) "Example(None, '

(type_str, *args, **kwargs)

Source from the content-addressed store, hash-verified

97
98
99def make_invocable_impl(type_str, *args, **kwargs):
100 """
101 Generates a string that would invoke the type specified in
102 type_str with the specified arguments.
103 Skips keyword arguments that are set to ``None``.
104
105 For example:
106 ::
107 >>> make_invocable_impl("Example", None, "string", w=None, x=2, y=inline("test"))
108 "Example(None, 'string', x=2, y=test)"
109
110 Args:
111 type_str (str): The type to invoke.
112
113 Returns:
114 Tuple[str, bool]:
115 A tuple including the `invoke` string and a boolean
116 indicating whether all the arguments were default (i.e. None).
117 """
118 # We don't need to check obj_str for safety since we know that any inline
119 # args/kwargs are already safe - other types need no checks
120 obj_str, all_args_default, all_kwargs_default = util.make_repr(type_str, *args, **kwargs)
121 return Script.String(obj_str, safe=True, inline=True), all_args_default, all_kwargs_default
122
123
124@mod.export()

Callers 3

make_invocableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected