Anyone successful converting tensorflow resnet50 model to nnvm?

Hi,

Has anyone succeeded in converting tensorflow resnet50 model to nnvm?

I used the pretrained model ResNet-50 v2 from https://github.com/tensorflow/models/tree/master/official/resnet. The model is in saved_model format. I freezed the model by

python freeze_graph.py --input_saved_model_dir=saved_model_dir --output_graph=frozen_model.pb --output_node_names=ArgMax --clear_devices

Freezing was successful.

Then I followed the tvm tensorflow tutorial to convert this frozen model. However, an error occurred: “Operator Transpose not implemented”.

Any advice on converting a tensorflow resnet50 model to nnvm?

Thanks

We do support Transpose now. Can you check with latest code ?

On latest code Resnet50 has another dependency on mean (weighted mean).

brings in basic mean operator support which can be enhanced to support weights.

Hi Siva,

Thanks for your reply. I tried the latest tvm, and the Transpose operator is supported, but I got another error: not implemented: set([u’Mean’]).

You may proceed with above Mean patch and add weighted version to it or wait for a while to get it merged in mainline.

@srkreddy1238

I tried the latest tvm code with the above pr merged. Two issues:

  1. ‘Mean’ is not added to _convert_map in tvm/nnvm/python/nnvm/frontend/tensorflow.py (same to prod, but my resnet50 model does not have prod operator). So the not implemented error still got raised.

  2. [Solved] ‘Transpose’ input can be an int array like [0 3 1 2], but tvm/nnvm/python/nnvm/compiler/build_module.py just defaults all the input dtype to ‘float32’, so it raises ValueError in _update_shape_dtype like: resnet_model/transpose/perm: dtype not expected float32 vs int32.

I tried to play with the source code, but got other errors. Could you, or other tf contributors look at these two issues? Thanks!

#2 could be solved by passing dtype as a dict like:

dtype_dict = {'resnet_model/transpose/perm': 'int32'}
graph, lib, params = nnvm.compiler.build(sym, target, shape_dict, dtype=dtype_dict, params=params)

Ref: ONNX error when compiling with nnvm

Complete patch for Resnet models.

Ref. Teach NNVM recognize tensorflow model

Supports all Resnet models now.