kmkurn / pytorch-crf

(Linear-chain) Conditional random field in PyTorch.

Home Page:https://pytorch-crf.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pytorch-crf model to onnx conversion

9lan9 opened this issue · comments

Actually, it is the same issue in pytorch/pytorch#39245, any solution for this one?

I personally never used ONNX, so I don't think I can help, sorry! I'll keep the issue open in case anyone else can help.

I personally never used ONNX, so I don't think I can help, sorry! I'll keep the issue open in case anyone else can help.

ok, thanks.

commented

output of _viterbi_decode is a list of int lists with variable lengths which is invalid for onnx output.
just convert it to a tensor. for example:
image

output of _viterbi_decode is a list of int lists with variable lengths which is invalid for onnx output.
just convert it to a tensor. for example:
image

convert list to tensor would cause problems, that's the problem

commented

Cannot convert the CRF layer to ONNX even using the latest version of PyTorch. I guess the combination of some operators may cause issues in PyTorch converter. And it also cannot be converted to torchscript. Here is the version of CRF that can be converted torchscript: https://github.com/facebookresearch/pytext/blob/master/pytext/models/crf.py . Unfortunately, CRF code provided by pytext also cannot be converted to ONNX

commented

pytorch model is converted to ONNX via torchscript,
this issue is related #79