tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [incubator-tvm] lfengad commented on a change in pull request #5042: [TF][Relay] TensorFlow Frontend support with shared params
Date Fri, 13 Mar 2020 04:33:12 GMT
lfengad commented on a change in pull request #5042: [TF][Relay] TensorFlow Frontend support
with shared params

 File path: tests/python/frontend/tensorflow/
 @@ -0,0 +1,65 @@
+# 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
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+Operators sharing the same param testcases
+This is a test script to test the support of shared
+params among operators in TensorFlow frontend.
+import tvm
+import numpy as np
+import tensorflow as tf
+from tvm import relay
+from tensorflow.python.framework import graph_util
+def test_sharing_node():
+    g = tf.Graph()
+    with g.as_default():
+        input_tensor = tf.placeholder(tf.float32, shape=(2, 2, 2), name='input')
+        axis = tf.constant([-1], dtype=tf.int32, name='axis')
+        mean0 = tf.reduce_mean(input_tensor, axis=axis, keepdims=False, name='mean0')
+        mean1 = tf.reduce_mean(input_tensor, axis=axis, keepdims=False, name='mean1')
+        add = tf.add(mean0, mean1, name='sum')
+        out = tf.identity(add, name='output')
+    data = np.random.rand(2, 2, 2)
+    with tf.Session(graph=out.graph) as sess:
+        tf_out =, feed_dict={input_tensor:data})
+        constant_graph = graph_util.convert_variables_to_constants(sess, sess.graph_def,
+    for device in ["llvm"]:
+        ctx = tvm.context(device, 0)
+        if not ctx.exist:
+            print("Skip because %s is not enabled" % device)
+            continue
+        mod, params = relay.frontend.from_tensorflow(constant_graph,
+                                                     outputs=['output'])
+        with relay.build_config(opt_level=3):
+            graph, lib, params =,
 Review comment:
   Hi, I have already modified the code according to both suggestions from you two! Thank
you so much! 

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:

With regards,
Apache Git Services

View raw message