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)

你可能感兴趣的:(onnx生成失败)