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

Function _uniquify_fetches

tensorflow/python/client/session.py:334–367  ·  view source on GitHub ↗

Uniquifies fetches from a list of fetch_mappers. This is a utility function used by _ListFetchMapper and _DictFetchMapper. It gathers all the unique fetches from a list of mappers and builds a list containing all of them but without duplicates (unique_fetches). It also returns a 2-D list

(fetch_mappers)

Source from the content-addressed store, hash-verified

332
333
334def _uniquify_fetches(fetch_mappers):
335 """Uniquifies fetches from a list of fetch_mappers.
336
337 This is a utility function used by _ListFetchMapper and _DictFetchMapper. It
338 gathers all the unique fetches from a list of mappers and builds a list
339 containing all of them but without duplicates (unique_fetches).
340
341 It also returns a 2-D list of integers (values_indices) indicating at which
342 index in unique_fetches the fetches of the mappers are located.
343
344 This list is as follows:
345 values_indices[mapper_index][mapper_fetch_index] = unique_fetches_index
346
347 Args:
348 fetch_mappers: list of fetch mappers.
349
350 Returns:
351 A list of fetches.
352 A 2-D list of integers.
353 """
354 unique_fetches = []
355 value_indices = []
356 seen_fetches = object_identity.ObjectIdentityDictionary()
357 for m in fetch_mappers:
358 m_value_indices = []
359 for f in m.unique_fetches():
360 j = seen_fetches.get(f)
361 if j is None:
362 j = len(seen_fetches)
363 seen_fetches[f] = j
364 unique_fetches.append(f)
365 m_value_indices.append(j)
366 value_indices.append(m_value_indices)
367 return unique_fetches, value_indices
368
369
370class _ListFetchMapper(_FetchMapper):

Callers 3

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls 3

unique_fetchesMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected