WeNet

ONNX

当前仓库代码在于魔改原始WeNet源码,使其可以进行onnx导出

Quick start

配置好examples/onnx/run_onnx.sh里面的config,checkpoint,output_dir

默认使用transformer

cd examples/onnx/
./run_onnx.sh

导出的模型可以使用wenet online onnx decoder代码进行测试

现在可以完成的工作

修改基本思路

参考原始wenet源码

参考作业帮给出部分的方案

所有的对Tensor取size的操作均不被onnx支持,所以要把其包在@torch.jit.script指示的函数里

对文件的修改记录

添加的文件

环境配置

环境配置请参考wenet

现存的可能的bug

Traceback (most recent call last):
File "onnx_decoder.py", line 198, in <module>
np.testing.assert_allclose(to_numpy(torch_outputs[i]), ort_outs[0], rtol=1e-03, atol=1e-05,err_msg='{0}'.format(i))

AssertionError:
Not equal to tolerance rtol=0.001, atol=1e-05
Mismatched elements: 761 / 2839200 (0.0268%)
Max absolute difference: 0.00216645
Max relative difference: 7.25