onnx生成失败

一些层在onnx中不予支持。例如,AdapativeAvgPool2d。

The reason is that LayoutLMv2 uses a visual backbone, which includes layers like AdapativeAvgPool2d which aren't supported natively by ONNX. https://github.com/huggingface/transformers/issues/14368

When you transform a Pytorch model to ONNX, using torch.onnx.export, you might add option operator_export_type=torch.onnx.OperatorExportTypes.ONNX_ATEN_FALLBACK to allow you to use ops in Aten when cannot find it in ONNX operator set. It works for me, when I use torch.nn.AdaptiveAvgPool2d in a PyTorch network. https://github.com/pytorch/pytorch/issues/14395#issuecomment-444697403

torch.onnx._export(net,input,path,export_params=False,
operator_export_type=torch.onnx.OperatorExportTypes.ONNX_ATEN_FALLBACK)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容