-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Make test/node generation produce models with since_version by default #3855
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
Conversation
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
if 'opset_imports' not in kwargs: | ||
# To make sure the model will be produced with the same opset_version after opset changes | ||
# By default, it uses since_version as opset_version for produced models | ||
since_version = onnx.defs.get_schema(node.op_type, node.domain).since_version |
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.
use max_inclusive_version for fetching schema to make sure we fetch the right schema for tests IF they target an older opset. Today none of the tests do but it is best if we add this check.
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.
Good point. I have updated get_schema with max_inclusive_version and make target opset_version as use_max_opset_version, which is more accurate. It takes some time for to inspect whether there is any updated model. Will update them later.
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 takes some time for to inspect whether there is any updated model.
If you run your script and do a git diff that should tell you right?
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.
There might be other changes due to system difference... To be careful, I will go through all of them (perhaps write a simple script to detect it).
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.
Eventually I wrote a script for only updating models/output.pb if their opset_version have been changed by this PR. However, there are 566 models which need to be updated (864 models in total). This PR will impact projects which are relying on backend test data.
One of the reasons why so many models are affected is -- typically an opset bump only involves some conditions and mostly only they were updated. Then the other models of other conditions would still use an old opset_version.
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.
in that case we can change the test to include max_inclusive_version parameter to restrict the model to older opset
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.
going forward this should not be a problem... we should ask the authors to update all the models for the changing op... infact it will be gated by the git diff check in the PR.
So basically the author will have 2 options - update the test to include max_inclusive_version or simply update all the test data.
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.
added comments
…e targeted opset version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
4593922
to
7a8d7a7
Compare
@@ -1 +1 @@ | |||
{"atol": 1e-07, "model_name": "zfnet512", "rtol": 0.001, "url": "https://s3.amazonaws.com/download.onnx/models/opset_9/zfnet512.tar.gz"} |
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.
Based on the specified opset version here:
base_model_opset_version = 10 |
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
This PR will forward after 1.11 release since it involves too many files and makes a fundamental change about data generation. Here is the summary that data generation behavior will be changed as follows: Previous
New
|
Signed-off-by: jcwchen <jacky82226@gmail.com>
Update: I am trying to test the consistency of test generation in CIs. It seems that only Windows CI can have exactly the same node tests as this PR (I updated these node test models on Windows). I suspect there is an issue like this one: #3120. Still investigating. |
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
This issue exists because NumPy functions might behave differently on different platforms. Therefore skip all output.pb and some input.pb for now. I have added test generation in Windows CI, Linux CI and Mac CI in this PR. At least all ONNX models produced by test generation are consistent. |
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
One last update: I tried to bump the latest opset version and see whether any test has updated. Then I figured out simple tests still used make_model without specifying opset version so it will keep changing if the latest opset version bumps. To solve this, I further use make_mode_gen_version and specify opset version to make this test generation consistent. |
overall the PR looks good to me. I suggest using this branch in ort CIs and make sure all pipelines are green. |
Signed-off-by: jcwchen <jacky82226@gmail.com>
Thanks for the review! I have verified these updated models once in ORT CIs and there isn't any related failure: microsoft/onnxruntime#11214 |
onnx#3855) * add since_version for data generation Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * specify opset_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * int str opset_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix typecheck Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * flake 8 Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * do not set opset_imports if it has been specified Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix typecheck Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * use_max_opset_version for the latest opset vesion that supports before targeted opset version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix bug use_max_opset_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * update 566 models Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * apply max_inclusive_version to opset_imports Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix flake8 Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * revert onehot's input_1.pb change Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * update onehot because 0d update Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * update helper and tools for older ir_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix helper Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * use IR_VERSION according to the opset_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix flake8 Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * if unknown newer opset_version, use default ir_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix undefined opset_version globally Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * use make_model_gen_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * remove useless '' handling Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * handle newer opset_version for undefined IR_VERSION Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * use _make_test_model_gen_version to handle unrelease opset version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * traverse opset_imports correctly Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * ignore reasonable unpack case Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * directly use specified opset version; try CI Signed-off-by: jcwchen <jacky82226@gmail.com> * test Windows CI as well Signed-off-by: jcwchen <jacky82226@gmail.com> * update layer norm by Windows Signed-off-by: jcwchen <jacky82226@gmail.com> * .astype(np.float32) for acosh Signed-off-by: jcwchen <jacky82226@gmail.com> * update operator.doc Signed-off-by: jcwchen <jacky82226@gmail.com> * test_coverage.md Signed-off-by: jcwchen <jacky82226@gmail.com> * float64 instead of float32 Signed-off-by: jcwchen <jacky82226@gmail.com> * int64 for negativeloss and apply Mac CI, exclude .output.pb Signed-off-by: jcwchen <jacky82226@gmail.com> * remove target version for now Signed-off-by: jcwchen <jacky82226@gmail.com> * use ! instead of exclude on Mac Signed-off-by: jcwchen <jacky82226@gmail.com> * skip test_log's input due to numpy.random Signed-off-by: jcwchen <jacky82226@gmail.com> * specify opset_imports for simple tests for consistency Signed-off-by: jcwchen <jacky82226@gmail.com> * make_model_gen_version Signed-off-by: jcwchen <jacky82226@gmail.com> * update operators and testcoverage Signed-off-by: jcwchen <jacky82226@gmail.com> * nit: better error messages Signed-off-by: jcwchen <jacky82226@gmail.com> Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
onnx#3855) * add since_version for data generation Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * specify opset_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * int str opset_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix typecheck Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * flake 8 Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * do not set opset_imports if it has been specified Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix typecheck Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * use_max_opset_version for the latest opset vesion that supports before targeted opset version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix bug use_max_opset_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * update 566 models Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * apply max_inclusive_version to opset_imports Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix flake8 Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * revert onehot's input_1.pb change Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * update onehot because 0d update Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * update helper and tools for older ir_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix helper Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * use IR_VERSION according to the opset_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix flake8 Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * if unknown newer opset_version, use default ir_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * fix undefined opset_version globally Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * use make_model_gen_version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * remove useless '' handling Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * handle newer opset_version for undefined IR_VERSION Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * use _make_test_model_gen_version to handle unrelease opset version Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * traverse opset_imports correctly Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * ignore reasonable unpack case Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com> * directly use specified opset version; try CI Signed-off-by: jcwchen <jacky82226@gmail.com> * test Windows CI as well Signed-off-by: jcwchen <jacky82226@gmail.com> * update layer norm by Windows Signed-off-by: jcwchen <jacky82226@gmail.com> * .astype(np.float32) for acosh Signed-off-by: jcwchen <jacky82226@gmail.com> * update operator.doc Signed-off-by: jcwchen <jacky82226@gmail.com> * test_coverage.md Signed-off-by: jcwchen <jacky82226@gmail.com> * float64 instead of float32 Signed-off-by: jcwchen <jacky82226@gmail.com> * int64 for negativeloss and apply Mac CI, exclude .output.pb Signed-off-by: jcwchen <jacky82226@gmail.com> * remove target version for now Signed-off-by: jcwchen <jacky82226@gmail.com> * use ! instead of exclude on Mac Signed-off-by: jcwchen <jacky82226@gmail.com> * skip test_log's input due to numpy.random Signed-off-by: jcwchen <jacky82226@gmail.com> * specify opset_imports for simple tests for consistency Signed-off-by: jcwchen <jacky82226@gmail.com> * make_model_gen_version Signed-off-by: jcwchen <jacky82226@gmail.com> * update operators and testcoverage Signed-off-by: jcwchen <jacky82226@gmail.com> * nit: better error messages Signed-off-by: jcwchen <jacky82226@gmail.com>
Description
P.S. since_version is the version of the operator set that this operator was initially declared in.
More details about changed behaviors please see the comment here.
Motivation and Context
Closes #2629 Currently test generation will always produce models with the latest opset_version. However, if we want to test "test generation" in CIs with the same situation when they were uploaded, test generation should be always consistent regardless of which platform. To achieve that, make_model_gen_version with specified since_version is needed.