fanwei-china commented on issue #6931:
URL: https://github.com/apache/incubator-tvm/issues/6931#issuecomment-728785484


   the tensorflow frontend code is:
   with tf_compat_v1.gfile.GFile(model_path, 'rb') as f:
         graph_def = tf_compat_v1.GraphDef()
         graph_def.ParseFromString(f.read())
         graph = tf.import_graph_def(graph_def, name='')
         # Call the utility to import the graph definition into default graph.
         graph_def = tf_testing.ProcessGraphDefParam(graph_def)
         # Add shapes to the graph.
         with tf_compat_v1.Session() as sess:
             graph_def = tf_testing.AddShapesToGraphDef(sess, 
'bert/cls/predictions/label_score')
    
     qt = np.full((512, 50), 1, "int32")
     qt_mask = np.full((512, 50), 1.1, "float32")
     site = np.full((512, 1), 1, "int32")
     o_k = np.full((512, 10), 1, "int32")
     o_k_m = np.full((512, 10), 1.1, "float32")
     n_k = np.full((512, 10), 1, "int32")
     n_k_m = np.full((512, 10), 1.1, "float32")
     n_k_i = np.full((512, 10), 1, "int32")
     n_k_o = np.full((512, 10), 1, "int32")
    
     # Import the graph to Relay
     # -------------------------
     # Import tensorflow graph definition to relay frontend.
     #
     # Results:
     #   sym: relay expr for given tensorflow protobuf.
     #   params: params converted from tensorflow params (tensor protobuf).
     shape_dict = {
             'qt_sent': qt.shape,
             'qt_mask': qt_mask.shape,
             'url_sent': site.shape,
             'keyword_in': o_k.shape,
            'keyword_mask': o_k_m.shape,
            'n_keyword_in': n_k.shape,
            'n_keyword_mask':n_k_m.shape,
            'n_keyword_imp': n_k_i.shape,
            'n_keyword_occ': n_k_o.shape}
   
     mod, params = relay.frontend.from_tensorflow(graph_def,
                                                layout=layout,
                                                 shape=shape_dic)


----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to