k2-fsa / icefall

https://k2-fsa.github.io/icefall/
Apache License 2.0
892 stars 287 forks source link

Warning about initializer in onnx exported model #1274

Open nshmyrev opened 11 months ago

nshmyrev commented 11 months ago

When you export non-streaming zipformer2 model to onnx using export-onnx script, the result model causes many warnings in sherpa:

2023-09-25 22:18:11.589877696 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '/encoder/5/encoder/encoder_pos/Constant_37_output_0'. It is not used by any node and should be removed from the model.
2023-09-25 22:18:11.589890536 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '/encoder/5/encoder/encoder_pos/Constant_39_output_0'. It is not used by any node and should be removed from the model.

the source is this commit:

https://github.com/kakashidan/icefall/pull/2

another strange thing that it is not used in streaming:

https://github.com/k2-fsa/icefall/blob/master/egs/librispeech/ASR/zipformer/export-onnx-streaming.py#L680

compare to non-streaming

https://github.com/k2-fsa/icefall/blob/master/egs/librispeech/ASR/zipformer/export-onnx.py#L527

removing is_onnx=True doesn't seem to affect the accuracy

csukuangfj commented 11 months ago

another strange thing that it is not used in streaming:

The reason is that during streaming inference, the input chunk size is fixed, whereas it is a variable in the non-streaming case.

csukuangfj commented 11 months ago

removing is_onnx=True doesn't seem to affect the accuracy

If you change the input wave duration, i.e., use a larger value than the initial length of the positional encoding vector, you will get an error, I think.