From 425b9023c3e808782b82815c39ac6432ab932928 Mon Sep 17 00:00:00 2001 From: Amit Srivastava Date: Wed, 13 Mar 2019 14:13:14 +0530 Subject: [PATCH 1/8] Replaced get_shape() with shape. This is the recommended method to use. --- tensorflow/lite/toco/python/toco_from_protos_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/lite/toco/python/toco_from_protos_test.py b/tensorflow/lite/toco/python/toco_from_protos_test.py index 34cfd2c59fd..cc0d6f748ac 100644 --- a/tensorflow/lite/toco/python/toco_from_protos_test.py +++ b/tensorflow/lite/toco/python/toco_from_protos_test.py @@ -54,7 +54,7 @@ class TocoFromProtosTest(googletest.TestCase): model_flags = model_flags_pb2.ModelFlags() input_array = model_flags.input_arrays.add() input_array.name = TensorName(in_tensor) - input_array.shape.dims.extend(map(int, in_tensor.get_shape())) + input_array.shape.dims.extend(map(int, in_tensor.shape)) model_flags.output_arrays.append(TensorName(out_tensor)) # Shell out to run toco (in case it crashes) with tempfile.NamedTemporaryFile() as fp_toco, \ From bd6e2c5a426ee61ddc2e469f61c80081ad41db70 Mon Sep 17 00:00:00 2001 From: Amit Srivastava Date: Wed, 13 Mar 2019 14:15:38 +0530 Subject: [PATCH 2/8] Replaced get_shape() with shape. This is the recommended method to use. --- tensorflow/lite/python/lite.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tensorflow/lite/python/lite.py b/tensorflow/lite/python/lite.py index f99340fa516..fc8ae7790fc 100644 --- a/tensorflow/lite/python/lite.py +++ b/tensorflow/lite/python/lite.py @@ -258,14 +258,14 @@ class TFLiteConverterV2(object): # Checks dimensions in input tensor. for tensor in input_tensors: # Note that shape_list might be empty for scalar shapes. - shape_list = tensor.get_shape().as_list() + shape_list = tensor.shape.as_list() if None in shape_list[1:]: raise ValueError( "None is only supported in the 1st dimension. Tensor '{0}' has " "invalid shape '{1}'.".format(_tensor_name(tensor), shape_list)) elif shape_list and shape_list[0] is None: # Set the batch size to 1 if undefined. - shape = tensor.get_shape().as_list() + shape = tensor.shape.as_list() shape[0] = 1 tensor.set_shape(shape) @@ -411,7 +411,7 @@ class TFLiteConverter(object): Args: graph_def: Frozen TensorFlow GraphDef. input_tensors: List of input tensors. Type and shape are computed using - `foo.get_shape()` and `foo.dtype`. + `foo.shape` and `foo.dtype`. output_tensors: List of output tensors (only .name is used from this). input_arrays_with_shape: Tuple of strings representing input tensor names and list of integers representing input shapes @@ -460,7 +460,7 @@ class TFLiteConverter(object): Args: sess: TensorFlow Session. input_tensors: List of input tensors. Type and shape are computed using - `foo.get_shape()` and `foo.dtype`. + `foo.shape` and `foo.dtype`. output_tensors: List of output tensors (only .name is used from this). Returns: @@ -678,7 +678,7 @@ class TFLiteConverter(object): # Checks dimensions in input tensor. if self._has_valid_tensors(): for tensor in self._input_tensors: - shape = tensor.get_shape() + shape = tensor.shape if not shape: raise ValueError("Provide an input shape for input array " "'{0}'.".format(_tensor_name(tensor))) @@ -808,7 +808,7 @@ class TFLiteConverter(object): "use input_shapes parameter.") for tensor in self._input_tensors: - shape = tensor.get_shape().as_list() + shape = tensor.shape.as_list() shape[0] = batch_size tensor.set_shape(shape) From 0837fa288e8331e928c651ba582edd0150daf07d Mon Sep 17 00:00:00 2001 From: Amit Srivastava Date: Wed, 13 Mar 2019 14:17:10 +0530 Subject: [PATCH 3/8] Replaced get_shape() with shape. This is the recommended method to use. --- tensorflow/lite/python/convert_saved_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/lite/python/convert_saved_model.py b/tensorflow/lite/python/convert_saved_model.py index f8d986b7469..fcc92b79aca 100644 --- a/tensorflow/lite/python/convert_saved_model.py +++ b/tensorflow/lite/python/convert_saved_model.py @@ -215,7 +215,7 @@ def set_tensor_shapes(tensors, shapes): tensor.set_shape(shape) except ValueError as error: message = ("The shape of tensor '{0}' cannot be changed from {1} to " - "{2}. {3}".format(name, tensor.get_shape(), shape, + "{2}. {3}".format(name, tensor.shape, shape, str(error))) raise ValueError(message) From 359876ee27b4efe9e20fce91c2f10e30c8e8c6c1 Mon Sep 17 00:00:00 2001 From: Amit Srivastava Date: Wed, 13 Mar 2019 14:18:53 +0530 Subject: [PATCH 4/8] Replaced get_shape() with shape. This is the recommended method to use. --- tensorflow/lite/python/convert.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tensorflow/lite/python/convert.py b/tensorflow/lite/python/convert.py index 4d38ee9be49..b933ef1ea04 100644 --- a/tensorflow/lite/python/convert.py +++ b/tensorflow/lite/python/convert.py @@ -244,7 +244,7 @@ def build_toco_convert_protos(input_tensors, Args: input_tensors: List of input tensors. Type and shape are computed using - `foo.get_shape()` and `foo.dtype`. + `foo.shape` and `foo.dtype`. output_tensors: List of output tensors (only .name is used from this). inference_type: Target data type of real-number arrays in the output file. Must be `{tf.float32, tf.uint8}`. (default tf.float32) @@ -347,7 +347,7 @@ def build_toco_convert_protos(input_tensors, "inference_input_type is QUANTIZED_UINT8.") input_array.mean_value, input_array.std_value = quantized_input_stats[idx] if input_shapes is None: - shape = input_tensor.get_shape() + shape = input_tensor.shape else: shape = input_shapes[idx] input_array.shape.dims.extend(map(int, shape)) @@ -423,7 +423,7 @@ def toco_convert_impl(input_data, input_tensors, output_tensors, *args, Args: input_data: Input data (i.e. often `sess.graph_def`), input_tensors: List of input tensors. Type and shape are computed using - `foo.get_shape()` and `foo.dtype`. + `foo.shape` and `foo.dtype`. output_tensors: List of output tensors (only .name is used from this). *args: See `build_toco_convert_protos`, **kwargs: See `build_toco_convert_protos`. @@ -456,7 +456,7 @@ def toco_convert(input_data, input_tensors, output_tensors, *args, **kwargs): Args: input_data: Input data (i.e. often `sess.graph_def`), input_tensors: List of input tensors. Type and shape are computed using - `foo.get_shape()` and `foo.dtype`. + `foo.shape` and `foo.dtype`. output_tensors: List of output tensors (only .name is used from this). *args: See `build_toco_convert_protos`, **kwargs: See `build_toco_convert_protos`. From e19ae2228c99a8d394a0c7111555ed7650b812fd Mon Sep 17 00:00:00 2001 From: Amit Srivastava Date: Wed, 13 Mar 2019 14:20:20 +0530 Subject: [PATCH 5/8] Replaced get_shape() with shape. This is the recommended method to use. --- tensorflow/lite/testing/generate_examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/lite/testing/generate_examples.py b/tensorflow/lite/testing/generate_examples.py index 3ed2d551794..0537353d864 100644 --- a/tensorflow/lite/testing/generate_examples.py +++ b/tensorflow/lite/testing/generate_examples.py @@ -493,7 +493,7 @@ def make_zip_of_tests(zip_path, report["tf"] = report_lib.SUCCESS # Convert graph to toco input_tensors = [(input_tensor.name.split(":")[0], - input_tensor.get_shape(), input_tensor.dtype) + input_tensor.shape, input_tensor.dtype) for input_tensor in inputs] output_tensors = [normalize_output_name(out.name) for out in outputs] graph_def = freeze_graph( From 3f9c3d05329aec8af0330db66b0481d53658ee2a Mon Sep 17 00:00:00 2001 From: Amit Srivastava Date: Wed, 13 Mar 2019 14:22:07 +0530 Subject: [PATCH 6/8] Replaced get_shape() with shape. This is the recommended method to use. --- tensorflow/lite/experimental/examples/lstm/rnn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/lite/experimental/examples/lstm/rnn.py b/tensorflow/lite/experimental/examples/lstm/rnn.py index 6fea4c2e998..e005d81e405 100644 --- a/tensorflow/lite/experimental/examples/lstm/rnn.py +++ b/tensorflow/lite/experimental/examples/lstm/rnn.py @@ -217,10 +217,10 @@ def dynamic_rnn(cell, parallel_iterations = parallel_iterations or 32 if sequence_length is not None: sequence_length = math_ops.cast(sequence_length, dtypes.int32) - if sequence_length.get_shape().rank not in (None, 1): + if sequence_length.shape.rank not in (None, 1): raise ValueError( "sequence_length must be a vector of length batch_size, " - "but saw shape: %s" % sequence_length.get_shape()) + "but saw shape: %s" % sequence_length.shape) sequence_length = array_ops.identity( # Just to find it in the graph. sequence_length, name="sequence_length") From 414b73d3cc319f44de9f5b038742d7364c9c98d8 Mon Sep 17 00:00:00 2001 From: Amit Srivastava Date: Wed, 13 Mar 2019 14:23:53 +0530 Subject: [PATCH 7/8] Replaced get_shape() with shape. This is the recommended method to use. --- tensorflow/lite/experimental/examples/lstm/rnn_cell.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/lite/experimental/examples/lstm/rnn_cell.py b/tensorflow/lite/experimental/examples/lstm/rnn_cell.py index a5bae8dd01f..ba2f7875563 100644 --- a/tensorflow/lite/experimental/examples/lstm/rnn_cell.py +++ b/tensorflow/lite/experimental/examples/lstm/rnn_cell.py @@ -436,9 +436,9 @@ class TFLiteLSTMCell(rnn_cell_impl.LayerRNNCell): aggregate="first", index_override=18) - input_size = inputs.get_shape().with_rank(2)[1] + input_size = inputs.shape.with_rank(2)[1] if input_size.value is None: - raise ValueError("Could not infer input size from inputs.get_shape()[-1]") + raise ValueError("Could not infer input size from inputs.shape[-1]") inputs_and_m_prev = array_ops.concat([inputs, m_prev], axis=1) From ad5c47fe1f62599b26687911ea9749006aa51ebb Mon Sep 17 00:00:00 2001 From: Amit Srivastava Date: Wed, 13 Mar 2019 14:25:19 +0530 Subject: [PATCH 8/8] Replaced get_shape() with shape. This is the recommended method to use. --- .../microfrontend/python/ops/audio_microfrontend_op.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/lite/experimental/microfrontend/python/ops/audio_microfrontend_op.py b/tensorflow/lite/experimental/microfrontend/python/ops/audio_microfrontend_op.py index 3d49482f4ec..52bad311436 100644 --- a/tensorflow/lite/experimental/microfrontend/python/ops/audio_microfrontend_op.py +++ b/tensorflow/lite/experimental/microfrontend/python/ops/audio_microfrontend_op.py @@ -96,7 +96,7 @@ def audio_microfrontend(audio, Raises: ValueError: If the audio tensor is not explicitly a vector. """ - audio_shape = audio.get_shape() + audio_shape = audio.shape if audio_shape.ndims is None: raise ValueError("Input to `AudioMicrofrontend` should have known rank.") if len(audio_shape) > 1: