openvino
openvino copied to clipboard
[TFL FE]: gelu: fix issue when approximate is not specified
Sometimes the approximate attribute is not specified in the .tflite file, we need to check its availability before retriving it, otherwise we might hit the 'Check 'opts != nullptr' failed' failure with calling get_attribute() directly.
Why is this issue not caught initially? please share a model to check on our side.
Hi @rkazants , the issue was not caught, as no matter with tf.keras.activations.gelu or tf.keras.ops.gelu or tf.nn.gelu, there is always this 'approximate' attribute in the generated .tflite file. In case the attribute is listed in the .tflite model file, I had verified frontend works in both 'true' and 'false' cases.
For model files, check them here: https://github.com/keyonjie/my_ai_learning/blob/main/gelu_approx_false.tflite and https://github.com/keyonjie/my_ai_learning/blob/main/gelu_approx_true.tflite
But during recent debugging with a customer model, I found that the 'approximate' attribute of the 'gelu' layer is not listed at all, and when using our FE to convert it, we are hitting issue 'Check 'opts != nullptr' failed' failure with calling get_attribute() directly, as mentioned in the commit message.
I am querying the customer about how they generated the gelu layer and the model file there, and then I can try to generate one similar model and share it here, but basically if you open it with netron.app and the gelu ops info looks like this:
Hi @rkazants I have rebased/reimplemented the fix to the latest base and verified it works for all 3 use cases: attribute 'approximate' = true, 'approximate' = false, and no 'approximate' attribute in the .tflite files.
Please help review it, thanks.
build_jenkins