Merge pull request #32202 from Huawei-MRC-OSI:check-name-types

PiperOrigin-RevId: 314626868
Change-Id: I58cf3f4f12b7f36b4ae226d3f371da3f429f20e3
This commit is contained in:
TensorFlower Gardener 2020-06-03 16:35:48 -07:00
commit 70fd126d3a
1 changed files with 6 additions and 0 deletions

View File

@ -117,6 +117,12 @@ def get_tensors_from_tensor_names(graph, tensor_names):
tensors = []
invalid_tensors = []
for name in tensor_names:
if not isinstance(name, six.string_types):
raise ValueError("Invalid type for a tensor name in the provided graph. "
"Expected type for a tensor name is 'str', instead got "
"type '{}' for tensor name '{}'".format(
type(name), name))
tensor = tensor_name_to_tensor.get(name)
if tensor is None:
invalid_tensors.append(name)