-
Notifications
You must be signed in to change notification settings - Fork 3.5k
to_onnx return ONNXProgram #20811
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
base: master
Are you sure you want to change the base?
to_onnx return ONNXProgram #20811
Conversation
Hi @Borda , a friendly ping for code review~ BTW, I'm wondering if there's any way to update the typing-extensions requirement during testing so that it could fit with onnxscript? Thanks. |
seems this to be the cause of issue:
I wonder what could be the reason behind this version pinning. error:
|
model.eval() | ||
|
||
ret = model.to_onnx(dynamo=True) | ||
assert isinstance(ret, torch.onnx.ONNXProgram) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it would be worth adding a check that verifies the output of the exported ONNX model matches the PyTorch model’s output (within tolerance)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could use the existed test test_if_inference_output_is_valid
for this purpose? I added an parametrized dynamo
to that unittest in the last commit as well.
Thank you ~.
src/lightning/pytorch/core/module.py
Outdated
file_path: Union[str, Path, BytesIO, None] = None, | ||
input_sample: Optional[Any] = None, | ||
**kwargs: Any, | ||
) -> Union["ONNXProgram", None]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's technically correct, but since we've only one type, what do you think about Optional["ONNXProgram"]
for readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I've changed it in the last commit. Thanks.
Yea, I think that's where the problem is, and there're two solutions for this.
Personally, I'd prefer the second one, but this probably would need some change to the ci config which I not familiar with. |
Hi @deependujha all the changes are completed, just left with the requirement part. And to answer your question, I think it's for testing the compatibility of all the requirements with the lowest supported version. |
What does this PR do?
Fixes #20810
Before submitting
PR review
Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
Reviewer checklist
📚 Documentation preview 📚: https://pytorch-lightning--20811.org.readthedocs.build/en/20811/