Error when importing TensorFlow models



I followed this tutorial on how to import TensorFlow models. But when I try to import a model I get the following error:

    NotImplementedError: The following operators are not implemented: {'ShapeN', 'OptimizeDataset', 'Assign', 'IteratorV2', 'MakeIterator', 'AddN', 'PrefetchDataset', 'ApplyMomentum', 'NoOp', 'RestoreV2', 'Conv2DBackpropFilter', 'IteratorToStringHandle', 'BatchDatasetV2', 'AssignAdd', 'Conv2DBackpropInput', 'SaveV2', 'SparseSoftmaxCrossEntropyWithLogits', 'RandomUniform', 'VariableV2', 'PreventGradient', 'MaxPoolGrad', 'BiasAddGrad', 'ReluGrad', 'BroadcastGradientArgs', 'ShuffleDataset', 'ParallelMapDataset', 'CacheDataset', 'ModelDataset', 'ParallelInterleaveDatasetV2', 'DivNoNan', 'IteratorGetNext', 'TensorSliceDataset'}

This happens with a few different models including ResNet50. Does that mean TVM doesn’t support all TensorFlow operations, and I therefore can’t import arbitrary TensorFlow models, or is there a way to solve this error?


TVM does not support all operators in all frontends. Depending on the frontend you will find some missing operators. In this case it seems that your model there is a significant amount of unsupported operators. Adding these operators to TVM is definitely not a trivial task if you are not familiar with the code basis. The easiest path in this case is to replace this operators with some equivalent construction. Sometimes, there are operators that are not really needed so you can try to simply your model.


Many of these operators are training nodes. They can be removed by calling ConvertVariablesToConstants and running a few TF GraphTransforms before exporting.