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

Function _validate_indices_list

tensorflow/python/debug/cli/tensor_format.py:406–426  ·  view source on GitHub ↗
(indices_list, formatted)

Source from the content-addressed store, hash-verified

404
405
406def _validate_indices_list(indices_list, formatted):
407 prev_ind = None
408 for ind in indices_list:
409 # Check indices match tensor dimensions.
410 dims = formatted.annotations["tensor_metadata"]["shape"]
411 if len(ind) != len(dims):
412 raise ValueError("Dimensions mismatch: requested: %d; actual: %d" %
413 (len(ind), len(dims)))
414
415 # Check indices is within size limits.
416 for req_idx, siz in zip(ind, dims):
417 if req_idx >= siz:
418 raise ValueError("Indices exceed tensor dimensions.")
419 if req_idx < 0:
420 raise ValueError("Indices contain negative value(s).")
421
422 # Check indices are in ascending order.
423 if prev_ind and ind < prev_ind:
424 raise ValueError("Input indices sets are not in ascending order.")
425
426 prev_ind = ind
427
428
429def _locate_elements_in_line(line, indices_list, ref_indices):

Callers 1

locate_tensor_elementFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected