Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export onnx will add Identity operator #602

Open
zhuyuanxiang opened this issue Sep 1, 2023 · 1 comment
Open

export onnx will add Identity operator #602

zhuyuanxiang opened this issue Sep 1, 2023 · 1 comment

Comments

@zhuyuanxiang
Copy link

When I wirte a multi-head model and export the model to onnx format, I will see the identity operator in the onnx file.

This onnx file can't be read by C++ application, and met the parse error.

I use to torch.load_state_dict() the parameters, then the onnx will be good.

input_sample = torch.Tensor(1, cfg.model.net.in_chan, *cfg.data.crop_size), "pred" ckpt_path = Path(cfg.ckpt_path) checkpoint = torch.load(ckpt_path) model.load_state_dict(checkpoint['state_dict']) onnx_path = ckpt_path.parent.joinpath(ckpt_path.stem + ".onnx") model.to_onnx( onnx_path, input_sample, verbose=True, opset_version=11, training=TrainingMode.EVAL, do_constant_folding=False, operator_export_type=OperatorExportTypes.ONNX_FALLTHROUGH, )

@zhuyuanxiang
Copy link
Author

zhuyuanxiang commented Sep 1, 2023

I had tried load_from_checkpoint(), which is lightning's function, and the identity operator will be added to onnx model.

Maybe it's lightning's bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant