Skip to content

Class ConvertModel failed with layer LayerNormalization. However, BatchNormalization succeeds. #51

@klae01

Description

@klae01

This is ipython code (at colab) which makes an error.

Code

!pip install tensorflow==2.6.4 onnx==1.12.0 onnx2pytorch git+https://github.com/onnx/tensorflow-onnx

import tensorflow as tf
import onnx

from onnx2pytorch import ConvertModel

with tf.device("/cpu:0"):
    tf_model = tf.keras.Sequential()
    tf_model.add(tf.keras.layers.Input((123,)))
    tf_model.add(tf.keras.layers.LayerNormalization())
    tf.keras.models.save_model(
        tf_model,
        "model.tf",
        overwrite=True,
        include_optimizer=False,
        save_format=None,
        signatures=None,
        options=None,
        save_traces=True
    )
!python -m tf2onnx.convert --saved-model model.tf --output model.onnx --opset 11 --verbose
onnx_model = onnx.load("model.onnx")
encoder_pth = ConvertModel(onnx_model)

Error Message

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
[<ipython-input-3-a685e6e12ecf>](https://localhost:8080/#) in <module>()
     22 get_ipython().system('python -m tf2onnx.convert --saved-model model.tf --output model.onnx --opset 11 --verbose')
     23 onnx_model = onnx.load("model.onnx")
---> 24 encoder_pth = ConvertModel(onnx_model)

1 frames
[/usr/local/lib/python3.7/dist-packages/onnx2pytorch/convert/operations.py](https://localhost:8080/#) in convert_operations(onnx_graph, opset_version, batch_dim, enable_pruning)
    278             if op is None:
    279                 raise NotImplementedError(
--> 280                     "Conversion not implemented for op_type={}.".format(node.op_type)
    281                 )
    282             else:

NotImplementedError: Conversion not implemented for op_type=ReduceSumSquare.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions