MCPcopy Create free account
hub / github.com/pytorch/pytorch / map_arg

Method map_arg

torch/_dynamo/variables/optimizer.py:88–101  ·  view source on GitHub ↗
(arg)

Source from the content-addressed store, hash-verified

86 """Get python values equivalent to the variable tracker args"""
87
88 def map_arg(arg):
89 if isinstance(arg, ConstantVariable):
90 return arg.as_python_constant()
91 elif isinstance(arg, ListVariable) and not arg.items:
92 return []
93 elif (
94 isinstance(arg, ConstDictVariable)
95 and isinstance(arg.source, GetItemSource)
96 and isinstance(arg.source.base, AttrSource)
97 and arg.source.base.member == "param_groups"
98 ):
99 return self.value.param_groups[arg.source.index]
100
101 raise ArgMappingException()
102
103 new_args = [map_arg(arg) for arg in args]
104 new_kwargs = {k: map_arg(v) for k, v in kwargs.items()}

Callers 13

split_moduleFunction · 0.80
optimize_for_inferenceFunction · 0.80
type_check_nodeMethod · 0.80
refine_nodeMethod · 0.80
load_argMethod · 0.80
replace_by_exampleMethod · 0.80
check_fnFunction · 0.80
_argsFunction · 0.80
reorder_for_localityFunction · 0.80

Calls 3

isinstanceFunction · 0.85
ArgMappingExceptionClass · 0.85
as_python_constantMethod · 0.45

Tested by

no test coverage detected