rohanmukh commented on a change in pull request #8074:
URL: https://github.com/apache/tvm/pull/8074#discussion_r635875512



##########
File path: tests/python/frontend/tensorflow2/test_sequential_models.py
##########
@@ -0,0 +1,118 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# pylint: disable=import-self, invalid-name, unused-argument, too-many-lines, 
len-as-condition, broad-except
+# pylint: disable=import-outside-toplevel, redefined-builtin
+"""TF2 to relay converter test: testing models built with 
tf.keras.Sequential()"""
+
+import tempfile
+import numpy as np
+import pytest
+import tensorflow as tf
+from tensorflow.python.framework.convert_to_constants import 
convert_variables_to_constants_v2
+
+from common import compare_tf_tvm
+from common import run_tf_code
+
+
+def run_sequential_model(model_fn, input_shape):
+    def get_input(shape):
+        _input = np.random.uniform(0, 1, shape).astype(dtype="float32")
+        return _input
+
+    def save_and_reload(_model):
+        with tempfile.TemporaryDirectory() as model_path:
+            tf.saved_model.save(_model, model_path)
+            loaded = tf.saved_model.load(model_path)
+            func = loaded.signatures["serving_default"]
+            frozen_func = convert_variables_to_constants_v2(func)
+        return frozen_func
+
+    def model_graph(model, input_shape):
+        _input = get_input(input_shape)
+        f = save_and_reload(model(input_shape))
+        _output = run_tf_code(f, _input)
+        gdef = f.graph.as_graph_def(add_shapes=True)
+        return gdef, _input, _output
+
+    compare_tf_tvm(*model_graph(model_fn, input_shape), vm=True, 
output_sig=None)
+
+
+def dense_model(input_shape, num_units=128):

Review comment:
       Thanks @trevor-m  I addressed the comments in the new commits.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to