Skip to content

Add Split-18 - num_outputs attribute, support for uneven tensor splitting #4481

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

Merged
merged 20 commits into from
Oct 3, 2022

Conversation

p-wysocki
Copy link
Contributor

Description

  • new num_outputs attribute
  • support for splitting tensors into uneven chunks added

Motivation and Context

Previously discussed in #4389

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
@gramalingam
Copy link
Contributor

LGTM, thanks! Just one minor comment above to clarify shapes for the zero-size tensor.

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Copy link
Member

@jcwchen jcwchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you can try to cherry-pick this PR: #4202 and see whether it helps to show the exact errors without seg fault.

If that PR is indeed helpful, I would say we should forward that PR for better debugging.

@p-wysocki p-wysocki added the topic: operator Issues related to ONNX operators label Sep 8, 2022
Copy link
Member

@jcwchen jcwchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I think my PR #4202 now needs a few updates for being compatible with #4470. We can try another way: to faster test the unknown failure in your local, perhaps you can try:

python setup.py install  # build ONNX with your PR
python onnx/backend/test/cmd_tools.py generate-data
git diff --exit-code --diff-filter=ADR -- . :!onnx/onnx-data.proto 

I suspect the number of input_.pb or output_.pb might be incorrect in your PR. If that is true, the commands above should show some files. If not, there might be other issues I don't know in input_.pb or output_.pb.

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
@p-wysocki
Copy link
Contributor Author

@jcwchen I ran the commands, they did not show any files. However, after removing test_driver.cc changes the CI started passing. I have no idea why it's passing now, maybe the issue was sporadic or has been fixed on master in the meantime. Thanks for the help!

Copy link
Member

@jcwchen jcwchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might figure out why previous CI has failed: some added test model files are not needed. I don't see where they are generated. For instance, test_uneven_split and test_uneven_split_opset18. I would suggest you clean all of added test files and then use python onnx/backend/test/cmd_tools.py generate-data to generated them again. Since related test was just removed due to recent ONNXIFI deprecation, I will add a similar check in CI to prevent future issues like it.

Another suggestion would be making test files naming convention consistent. For names of Split related tests, please use test_split_XXX_XXX. IMO, it will be helpful for users to search related test files.

@jcwchen
Copy link
Member

jcwchen commented Sep 28, 2022

FYI: to detect similar issue (introducing new node test directories without corresponding test script) I mentioned above, I added a CI check for it by this PR: #4514.

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
This reverts commit ea7621f.

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
@p-wysocki
Copy link
Contributor Author

@jcwchen I applied your suggestions, thanks! For some reason I assumed that script that generates data also removes the old files. I also approved your PR introducing a CI check for that, it sounds helpful. Test names also have been aligned.

@p-wysocki p-wysocki requested a review from jcwchen September 28, 2022 18:38
Copy link
Member

@jcwchen jcwchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the updates! Once you have updated TestCoverage.md by the updated test scripts , I think this PR is ready to go.

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
@p-wysocki p-wysocki requested a review from jcwchen September 29, 2022 10:33
@gramalingam
Copy link
Contributor

I might figure out why previous CI has failed: some added test model files are not needed. I don't see where they are generated. For instance, test_uneven_split and test_uneven_split_opset18. I would suggest you clean all of added test files and then use python onnx/backend/test/cmd_tools.py generate-data to generated them again. Since related test was just removed due to recent ONNXIFI deprecation, I will add a similar check in CI to prevent future issues like it.

Another suggestion would be making test files naming convention consistent. For names of Split related tests, please use test_split_XXX_XXX. IMO, it will be helpful for users to search related test files.

I think it would be helpful to update the AddNewOp document (may be as a helpful Troubleshooting tip at the end) to remind people to delete the old folder before generating test-cases. (If the CI can catch it, that would be great too.)

@gramalingam
Copy link
Contributor

I might figure out why previous CI has failed: some added test model files are not needed. I don't see where they are generated. For instance, test_uneven_split and test_uneven_split_opset18. I would suggest you clean all of added test files and then use python onnx/backend/test/cmd_tools.py generate-data to generated them again. Since related test was just removed due to recent ONNXIFI deprecation, I will add a similar check in CI to prevent future issues like it.
Another suggestion would be making test files naming convention consistent. For names of Split related tests, please use test_split_XXX_XXX. IMO, it will be helpful for users to search related test files.

I think it would be helpful to update the AddNewOp document (may be as a helpful Troubleshooting tip at the end) to remind people to delete the old folder before generating test-cases. (If the CI can catch it, that would be great too.)

Or, may be the test-case generator should delete the folder? (Of course, it could be a bit risky in case the user has some other file there ... may be warn the user if there is some extra files there perhaps.)

static const char* Split_ver18_doc =
R"DOC(Split a tensor into a list of tensors, along the specified 'axis'.
Either input 'split' or the attribute 'num_outputs' should be specified, but not both.
If the attribute 'num_outputs' is specified, then the tensor is split into equal sized parts.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update above line by adding the line from below If the tensor is not evenly splittable, the last chunk will be smaller.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done.

@jcwchen
Copy link
Member

jcwchen commented Sep 29, 2022

I think it would be helpful to update the AddNewOp document (may be as a helpful Troubleshooting tip at the end) to remind people to delete the old folder before generating test-cases. (If the CI can catch it, that would be great too.)

Sounds good. I will add sentence about it in AddNewOp.md in this PR as well: #4514. Also note that that PR will let CI to catch this kind of issue. Perhaps we can forward that PR first and have that verify this PR.

Or, may be the test-case generator should delete the folder? (Of course, it could be a bit risky in case the user has some other file there ... may be warn the user if there is some extra files there perhaps.)

Yes, but it seems possible that users would like to keep existing ones for some testing purposes? Therefore, to keep behavior consistent, I introduced --clean flag for generate_data for CI use (by default it is False so it won't clean original node directory automatically).

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Copy link
Member

@jcwchen jcwchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It passed the enhanced CI 💯 Thank you @p-wysocki for this PR and waiting! I will merge it soon.

@jcwchen jcwchen enabled auto-merge (squash) October 3, 2022 16:52
@jcwchen jcwchen merged commit 1b585ca into onnx:main Oct 3, 2022
broune pushed a commit to broune/onnx that referenced this pull request May 6, 2023
…ting (onnx#4481)

* Add Split-18

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Uneven split works for 1d

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Add Nd support and tests

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Update docs

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Minor change

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Apply linter changes

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Fix linter, add CR changes

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Apply black changes

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Update docs

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Update test files

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Revert "Update test files"

This reverts commit ea7621f.

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Update test files

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Align test names

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* update docs

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

* Add info about uneven split

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>

Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
Co-authored-by: Chun-Wei Chen <jacky82226@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: operator Issues related to ONNX operators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants