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

Method __init__

tensorflow/python/client/session.py:290–321  ·  view source on GitHub ↗

Creates an _ElementFetchMapper. This is the fetch mapper used for leaves in the fetch struct. Because of the expansions mechanism, a leaf can actually fetch more than one tensor. Also note that the fetches here can be just strings (tensor or op names) or any other object that the

(self, fetches, contraction_fn)

Source from the content-addressed store, hash-verified

288 """Fetch mapper for singleton tensors and ops."""
289
290 def __init__(self, fetches, contraction_fn):
291 """Creates an _ElementFetchMapper.
292
293 This is the fetch mapper used for leaves in the fetch struct. Because of
294 the expansions mechanism, a leaf can actually fetch more than one tensor.
295
296 Also note that the fetches here can be just strings (tensor or op names) or
297 any other object that the graph knows how to convert to a tensor, such as a
298 Variable. So we have to run each fetch through `as_graph_element()` to get
299 the corresponding tensor or op.
300
301 Args:
302 fetches: List of objects, as returned by a fetch_fn defined in
303 _REGISTERED_EXPANSIONS.
304 contraction_fn: Callable as returned by a fetch_fn.
305 """
306 self._unique_fetches = []
307 for fetch in fetches:
308 try:
309 self._unique_fetches.append(ops.get_default_graph().as_graph_element(
310 fetch, allow_tensor=True, allow_operation=True))
311 except TypeError as e:
312 raise TypeError('Fetch argument %r has invalid type %r, '
313 'must be a string or Tensor. (%s)' %
314 (fetch, type(fetch), str(e)))
315 except ValueError as e:
316 raise ValueError('Fetch argument %r cannot be interpreted as a '
317 'Tensor. (%s)' % (fetch, str(e)))
318 except KeyError as e:
319 raise ValueError('Fetch argument %r cannot be interpreted as a '
320 'Tensor. (%s)' % (fetch, str(e)))
321 self._contraction_fn = contraction_fn
322
323 def unique_fetches(self):
324 return self._unique_fetches

Callers

nothing calls this directly

Calls 3

typeFunction · 0.85
as_graph_elementMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected