MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / _check_fetch_list

Method _check_fetch_list

python/paddle/base/executor.py:2228–2258  ·  view source on GitHub ↗
(self, fetch_list)

Source from the content-addressed store, hash-verified

2226 return exe.run(feed)
2227
2228 def _check_fetch_list(self, fetch_list):
2229 is_fetch_var = lambda var: isinstance(var, (Variable, str, Value))
2230 is_tuple_list = lambda var: isinstance(var, (tuple, list))
2231
2232 if fetch_list is None:
2233 return []
2234 if is_fetch_var(fetch_list):
2235 return [fetch_list]
2236
2237 assert is_tuple_list(fetch_list), (
2238 "Currently , The fetch_list type only should be list or tuple, \n"
2239 f"but the input type is {type(fetch_list)}. For more information please refer to \n"
2240 "the executor.run(...)."
2241 )
2242
2243 res = []
2244 for i, var in enumerate(fetch_list):
2245 if is_fetch_var(var):
2246 res.append(var)
2247 # such as [x, 'mean_out', loss]
2248 elif is_tuple_list(var):
2249 if all(is_fetch_var(v) for v in var):
2250 res.extend(list(var))
2251 else:
2252 res.append(var)
2253 else:
2254 raise TypeError(
2255 f"Require fetch_list[{i}] 's type shall be one of (Value, str), but received {type(var).__name__}."
2256 )
2257
2258 return res
2259
2260 def _dump_debug_info(self, program=None, trainer=None):
2261 with open(str(id(program)) + "_train_desc.prototxt", "w") as fout:

Callers 3

_run_implMethod · 0.95
_run_pir_implMethod · 0.95

Calls 6

listFunction · 0.85
TypeErrorClass · 0.85
typeFunction · 0.50
allFunction · 0.50
appendMethod · 0.45
extendMethod · 0.45

Tested by 1