yongwww commented on a change in pull request #5699:
URL: https://github.com/apache/incubator-tvm/pull/5699#discussion_r434980636



##########
File path: tests/python/frontend/tensorflow/test_forward.py
##########
@@ -2238,6 +2258,40 @@ def test_forward_resnetv2():
                     tvm.testing.assert_allclose(np.squeeze(tvm_output[0]), 
np.squeeze(tf_output[0]),
                                                 rtol=1e-5, atol=1e-5)
 
+#######################################################################
+# SSD
+# ---
+
+
+def test_forward_ssd():
+    '''test resnet model'''

Review comment:
       ```suggestion
       '''test SSD with backbone MobileNet V1'''
   ```

##########
File path: tests/python/frontend/tensorflow/test_forward.py
##########
@@ -2238,6 +2258,40 @@ def test_forward_resnetv2():
                     tvm.testing.assert_allclose(np.squeeze(tvm_output[0]), 
np.squeeze(tf_output[0]),
                                                 rtol=1e-5, atol=1e-5)
 
+#######################################################################
+# SSD
+# ---
+
+
+def test_forward_ssd():
+    '''test resnet model'''
+    if is_gpu_available():
+        with tf.Graph().as_default():
+            graph_def = tf_testing.get_workload(
+                "object_detection/ssd_mobilenet_v1_ppn_shared_"
+                "box_predictor_300x300_coco14_sync_2018_07_03.pb")
+            # Call the utility to import the graph definition into default 
graph.
+            graph_def = tf_testing.ProcessGraphDefParam(graph_def)
+
+            data = np.random.uniform(0.0, 255.0, size=(1, 512, 512, 
3)).astype('float32')
+            in_node = "image_tensor"
+            out_node = ['detection_boxes', "detection_scores", 
"detection_classes"]
+
+            with tf.Session() as sess:
+                tf_output = run_tf_graph(
+                    sess, data, '{}:0'.format(in_node), ["{}:0".format(oname) 
for oname in out_node])
+                # TODO(kevinthesun): enable gpu test when VM heterogeneous 
execution is ready.
+                for device in ["llvm"]:
+                    ctx = tvm.context(device, 0)
+                    if not ctx.exist:
+                        print("Skip because %s is not enabled" % device)
+                        continue
+                    tvm_output = run_tvm_graph(graph_def, data, in_node, 
len(out_node),
+                                               target=device, layout="NCHW", 
mode="vm")
+                    for i in range(len(out_node)):
+                        tvm.testing.assert_allclose(tvm_output[i], 
tf_output[i],
+                                                    rtol=1e-3, atol=1e-3)

Review comment:
       ```suggestion
       def _test_forward_ssd(model_url, in_node, out_nodes, in_shape):
           graph_def = tf_testing.get_workload(model_url)
           # Call the utility to import the graph definition into default graph.
           graph_def = tf_testing.ProcessGraphDefParam(graph_def)
   
           data = np.random.uniform(0.0, 255.0, size=in_shape).astype('float32')
   
           with tf.Session() as sess:
               tf_output = run_tf_graph(
                   sess, data, '{}:0'.format(in_node), ["{}:0".format(oname) 
for oname in out_nodes])
               # TODO(kevinthesun): enable gpu test when VM heterogeneous 
execution is ready.
               for device in ["llvm"]:
                   ctx = tvm.context(device, 0)
                   if not ctx.exist:
                       print("Skip because %s is not enabled" % device)
                       continue
                   tvm_output = run_tvm_graph(graph_def, data, in_node, 
len(out_nodes),
                                              target=device, layout="NCHW", 
mode="vm")
                   for i in range(len(out_nodes)):
                       tvm.testing.assert_allclose(tvm_output[i], tf_output[i],
                                                   rtol=1e-3, atol=1e-3)
       _test_forward_ssd("object_detection/ssd_mobilenet_v1_ppn_shared_"
                         "box_predictor_300x300_coco14_sync_2018_07_03.pb",
                         "image_tensor",
                         ['detection_boxes', "detection_scores", 
"detection_classes"],
                         (1, 512, 512, 3))
   ```




----------------------------------------------------------------
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