• Home
  • Raw
  • Download

Lines Matching full:fetch

98 # `fetch_fn` describes how to expand fetch into its
115 (sparse_tensor.SparseTensor, lambda fetch: ([
116 fetch.indices, fetch.values, fetch.dense_shape
124 lambda fetch: ([fetch.values, fetch.indices] if fetch.dense_shape is None
125 else [fetch.values, fetch.indices, fetch.dense_shape
131 (object, lambda fetch: ([fetch], lambda fetched_vals: fetched_vals[0]),
148 """Register fetch and feed conversion functions for `tf.Session.run()`.
175 fetch_function describes how to expand fetch into its component Tensors
210 """Definition of the interface provided by fetch mappers.
212 Fetch mappers are utility classes used by the _FetchHandler to handle
213 arbitrary structures for the `fetch` argument to `Session.run()`.
215 The `fetch` argument can be of various shapes: single tensor or op, list of
225 """Return the list of unique tensors or ops needed by this fetch mapper.
234 """Build results that match the original shape of the fetch.
241 A struct of the same shape as the original fetch object handled by
242 this fetch mapper. In the returned struct, the original fetches are
248 def for_fetch(fetch): argument
249 """Creates fetch mapper that handles the structure of `fetch`.
251 The default graph must be the one from which we want to fetch values when
255 fetch: An arbitrary fetch structure: singleton, list, tuple, namedtuple,
261 if fetch is None:
262 raise TypeError(f'Argument `fetch` = {fetch} has invalid type '
263 f'"{type(fetch).__name__}". Cannot be None')
264 elif isinstance(fetch, (list, tuple)):
266 return _ListFetchMapper(fetch)
267 elif isinstance(fetch, collections_abc.Mapping):
268 return _DictFetchMapper(fetch)
269 elif _is_attrs_instance(fetch):
270 return _AttrsFetchMapper(fetch)
274 if isinstance(fetch, tensor_type):
275 fetches, contraction_fn = fetch_fn(fetch)
278 raise TypeError(f'Argument `fetch` = {fetch} has invalid type '
279 f'"{type(fetch).__name__}"')
283 """Fetch mapper for singleton tensors and ops."""
288 This is the fetch mapper used for leaves in the fetch struct. Because of
289 the expansions mechanism, a leaf can actually fetch more than one tensor.
293 Variable. So we have to run each fetch through `as_graph_element()` to get
302 for fetch in fetches:
305 fetch, allow_tensor=True, allow_operation=True))
307 raise TypeError(f'Argument `fetch` = {fetch} has invalid type '
308 f'"{type(fetch).__name__}" must be a string or Tensor. '
311 raise ValueError(f'Argument `fetch` = {fetch} cannot be interpreted as '
314 raise ValueError(f'Argument `fetch` = {fetch} cannot be interpreted as '
343 fetch_mappers: list of fetch mappers.
366 """Fetch mapper for lists, tuples, and namedtuples."""
378 self._mappers = [_FetchMapper.for_fetch(fetch) for fetch in fetches]
400 """Fetch mapper for dicts."""
417 _FetchMapper.for_fetch(fetch) for fetch in fetches.values()
434 """Fetch mapper for attrs decorated classes."""
444 self._mappers = [_FetchMapper.for_fetch(fetch) for fetch in values]
461 class takes care of generating a list of tensor names to fetch and op names
473 """Creates a fetch handler.
478 fetches: An arbitrary fetch structure: singleton, list, tuple, namedtuple,
492 for fetch in self._fetch_mapper.unique_fetches():
493 if isinstance(fetch, ops.Operation):
494 self._assert_fetchable(graph, fetch)
495 self._targets.append(fetch)
498 self._assert_fetchable(graph, fetch.op)
499 self._fetches.append(fetch)
501 # Remember the fetch if it is for a tensor handle.
502 if (isinstance(fetch, ops.Tensor) and
503 (fetch.op.type == 'GetSessionHandle' or
504 fetch.op.type == 'GetSessionHandleV2')):
505 self._fetch_handles[fetch.ref()] = fetch.op.inputs[0].dtype
517 """Return the unique names of tensors to fetch.
533 """Build results matching the original fetch shape.
537 fetch values.
559 # If the fetch was in the feeds, use the fed value, otherwise
562 # A fetch had a corresponding direct TensorHandle feed. Call eval()
1175 # Create a fetch handler to take care of the structure of fetches.
1213 fetches: A value or list of values to fetch. See `tf.Session.run` for
1214 details of the allowable fetch types.
1255 # Create a fetch handler to take care of the structure of fetches.