tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-tvm] lfengad opened a new pull request #5042: [TF][Relay] TensorFlow Frontend support with shared params
Date Wed, 11 Mar 2020 13:48:08 GMT
lfengad opened a new pull request #5042: [TF][Relay] TensorFlow Frontend support with shared
params
URL: https://github.com/apache/incubator-tvm/pull/5042
 
 
   We observe that in lots of tensorflow models used in our production environment, some operators
share the same node as their attributes. For example, there might be two "tf.reduce_mean"
operators each with its own "axis" attribute. Their "axis" attributes can take the same "tf.constant"
node. In this case, different operators share the same node as attributes. 
   
   However, in the current tensorflow frontend of relay, such sharing of the same param among
different operators is not supported. For example, in the current implementation of "_get_param"
function in "python/tvm/relay/frontend/tensorflow.py", the corresponding param will be deleted
permanently using "pop" from the "_params" dictionary after being checked in "_get_param"
function. In this case, if another operator needs to check the same param as its attribute,
that param will not be found. Hence, the current implementation of the tensorflow frontend
cannot support param sharing among different operators.   
   
   In order to support the case of param sharing among operators, we modify the tensorflow
frontend. We leverage on the python decorator method. Everytime "_get_param" is called, instead
of deleting the corresponding visited param as in the current implementation, we record it
into a "used_params" dictionary and keep it in the original "_params" dictionary, so that
another operator can still visit it in the following process. Then after the whole relay graph
completes building, we delete the params have been visited in "used_params" from "_params"
to generate the final "_params" output.
   
   Compared to the old implementation ,our new implementation doesn't delete the visited params
immediately in "_get_param", but records them and deletes them at the final step. In this
way, the case where different operators share the same param can be supported.  
    
   Any suggestions are welcome! @tqchen @FrozenGene

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


With regards,
Apache Git Services

Mime
View raw message