Closed rogordan closed 3 years ago
...tfhub model to onnx... ...statefulpartitionedcall_args_145...
The tfhub saved_models are known to have some conversion difficulties, especially for Keras/TF2 models.
Will update this thread shortly.
There are actually some older TF1 models on the same tfhub page, that also would serve my purpose, but with those I ran into a different problem.. there is no metagraph. I think I managed to add a metagraph by loading in the model using tf1 but then there are some other issues. There was a failure that mentioned a regex op.
There was a failure that mentioned a regex op.
If there's an operator (e.g. regex operator) that's not implemented in Onnx, you can add a custom-op (see the README) to convert the model. The main drawback is that the converted Onnx model will not run under an Onnx-based runtime -- the op needs to be implemented in the runtime to load/run the model successfully.
Another option is to compose the operator using elementary Onnx ops. 'regex' probably cannot be reduced to the ops in the latest opset however.
Having the same issue trying to convert the Universal Sentence Encoder to ONNX.
Is there any update as to the underlying problem? Is it some operator not yet supported in ONNX, or a problem with the conversion?
this is comes from a StatefulPartitionedCall op. We ask grappler to inline those but for some reason this doesn't work in this case (first model I see that has this). I think we'd need to inline those our self. I fear even if we do this we'll have issues - as far I know this is using tf.text which onnx does not have an equivalent for.
attr {
key: "f"
value {
func {
name: "__inference_pruned_2009"
}
}
}
My guess is the most problematic ops beyond the one in this thread will be the sentence piece encoder which is built into the tfhub model. It may be possible to find the op immediately after the encoder and convert only that section.
Regex would be one of the easiest things to reimplements since the graph nodes seem to list the match and replace.
For our case we thought about transferring the weights to a pytorch model but decided to save the engineering effort trying to figure out how to do this and instead find another alternative that plays better with ONNX.
we fixed this some time ago.
My interpretation is that this model will simply not be supported by ONNX, is there a way for me to verify this?
System
Win10 TF 2.1 tf2onnx 1.6
Task
I am trying to convert the following tfhub model to onnx: https://tfhub.dev/google/universal-sentence-encoder/4
Running the following command:
Lots of bad output, including:
But what crashes the process is:
Full Output: tf2onnx-output.txt