diff --git a/tensorflow/lite/python/util.py b/tensorflow/lite/python/util.py index 32a2d596629..9d1b55e5092 100644 --- a/tensorflow/lite/python/util.py +++ b/tensorflow/lite/python/util.py @@ -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)