MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / for_fetch

Method for_fetch

tensorflow/python/client/session.py:253–284  ·  view source on GitHub ↗

Creates fetch mapper that handles the structure of `fetch`. The default graph must be the one from which we want to fetch values when this function is called. Args: fetch: An arbitrary fetch structure: singleton, list, tuple, namedtuple, or dict. Returns: An in

(fetch)

Source from the content-addressed store, hash-verified

251
252 @staticmethod
253 def for_fetch(fetch):
254 """Creates fetch mapper that handles the structure of `fetch`.
255
256 The default graph must be the one from which we want to fetch values when
257 this function is called.
258
259 Args:
260 fetch: An arbitrary fetch structure: singleton, list, tuple, namedtuple,
261 or dict.
262
263 Returns:
264 An instance of a subclass of `_FetchMapper` that handles the shape.
265 """
266 if fetch is None:
267 raise TypeError('Fetch argument %r has invalid type %r' %
268 (fetch, type(fetch)))
269 elif isinstance(fetch, (list, tuple)):
270 # NOTE(touts): This is also the code path for namedtuples.
271 return _ListFetchMapper(fetch)
272 elif isinstance(fetch, collections_abc.Mapping):
273 return _DictFetchMapper(fetch)
274 elif _is_attrs_instance(fetch):
275 return _AttrsFetchMapper(fetch)
276 else:
277 # Look for a handler in the registered expansions.
278 for tensor_type, fetch_fn, _, _ in _REGISTERED_EXPANSIONS:
279 if isinstance(fetch, tensor_type):
280 fetches, contraction_fn = fetch_fn(fetch)
281 return _ElementFetchMapper(fetches, contraction_fn)
282 # Did not find anything.
283 raise TypeError('Fetch argument %r has invalid type %r' %
284 (fetch, type(fetch)))
285
286
287class _ElementFetchMapper(_FetchMapper):

Callers 5

__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
_should_traceMethod · 0.80

Calls 6

typeFunction · 0.85
_ListFetchMapperClass · 0.85
_DictFetchMapperClass · 0.85
_is_attrs_instanceFunction · 0.85
_AttrsFetchMapperClass · 0.85
_ElementFetchMapperClass · 0.85

Tested by

no test coverage detected