MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / decorated_func

Function decorated_func

tensorpack/models/tflayer.py:45–66  ·  view source on GitHub ↗
(inputs, *args, **kwargs)

Source from the content-addressed store, hash-verified

43 def decorator(func):
44 @functools.wraps(func)
45 def decorated_func(inputs, *args, **kwargs):
46 kwargs = map_common_tfargs(kwargs)
47
48 posarg_dic = {}
49 assert len(args) <= len(args_names), \
50 "Please use kwargs instead of positional args to call this model, " \
51 "except for the following arguments: {}".format(', '.join(args_names))
52 for pos_arg, name in zip(args, args_names):
53 posarg_dic[name] = pos_arg
54
55 ret = {}
56 for name, arg in six.iteritems(kwargs):
57 newname = name_mapping.get(name, None)
58 if newname is not None:
59 assert newname not in kwargs, \
60 "Argument {} and {} conflicts!".format(name, newname)
61 else:
62 newname = name
63 ret[newname] = arg
64 ret.update(posarg_dic) # Let pos arg overwrite kw arg, for argscope to work
65
66 return func(inputs, **ret)
67
68 return decorated_func
69

Callers

nothing calls this directly

Calls 5

map_common_tfargsFunction · 0.85
formatMethod · 0.80
joinMethod · 0.80
updateMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…