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

Function wrapped_func

tensorpack/tfutils/argscope.py:97–117  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

95
96 @wraps(func)
97 def wrapped_func(*args, **kwargs):
98 actual_args = copy.copy(get_arg_scope()[func.__name__])
99 actual_args.update(kwargs)
100 out_tensor = func(*args, **actual_args)
101 in_tensor = args[0]
102
103 ctx = get_current_tower_context()
104 name = func.__name__ if 'name' not in kwargs else kwargs['name']
105 if log_shape:
106 if ('tower' not in ctx.ns_name.lower()) or ctx.is_main_training_tower:
107 # we assume the first parameter is the most interesting
108 if isinstance(out_tensor, tuple):
109 out_tensor_descr = out_tensor[0]
110 else:
111 out_tensor_descr = out_tensor
112 logger.info("{:<12}: {} --> {}".format(
113 "'" + name + "'",
114 get_shape_str(in_tensor),
115 get_shape_str(out_tensor_descr)))
116
117 return out_tensor
118 wrapped_func.__argscope_enabled__ = True
119 return wrapped_func
120

Callers

nothing calls this directly

Calls 5

get_arg_scopeFunction · 0.85
get_shape_strFunction · 0.85
updateMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected