tensorflow-onnx icon indicating copy to clipboard operation
tensorflow-onnx copied to clipboard

Support for `LayerNormalization` from ONNX opset 17

Open pwuertz opened this issue 2 years ago • 4 comments

When converting a tensorflow.keras.layers.LayerNormalization layer to ONNX, tf2onnx currently decomposes layer normalizations into rather complex subgraphs with batch norms and more basic building blocks. Inference engines (like TensorRT in the following example) are hardly able to deduce the original layer norm op from the graph and will have to follow the instructions to the letter: image

Since ONNX version 17 however, tensorflow.keras.layers.LayerNormalization layers are directly convertible to ONNX LayerNormalization operators. This of course produces a much simpler and expressive ONNX graph and leaves more room for the inference engine for possible optimizations (ONNX-to-TensorRT example again): image

The current version of tf2onnx doesn't seem to produce those new LayerNormalization operators yet, at least not with tf2onnx.convert.from_keras(model, opset=17).

pwuertz avatar May 31 '23 12:05 pwuertz

Same issue. Is there any plan to support rewrite LayerNormalization(opset 17)when use tf‘s savedmodel format?

binbabou avatar Jun 09 '23 07:06 binbabou

Same issue for me.

charvey2718 avatar Jul 05 '23 21:07 charvey2718

I have a tentative fix in https://github.com/onnx/tensorflow-onnx/pull/2250. Feel free to take it over

ShuaiShao93 avatar Sep 27 '23 22:09 ShuaiShao93