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

support for zero dimension tensors as an input for cat operation #2354

Merged
merged 2 commits into from
Oct 8, 2024

Conversation

jirmasek
Copy link
Contributor

@jirmasek jirmasek commented Oct 2, 2024

This PR introduces support for conversion of torch cat operation that has as an input a list of empty tensors (tensors with one of its dimensions being zero).

Without this fix we'd filter all these empty tensors and subsequently fail on determining the dtype of the output (as we'd have nothing in the input). We basically keep at least one of the empty tensors in the input to make sure dtype information is still available.

Fixes the bug in #2296.

CI pipeline: https://gitlab.com/coremltools1/coremltools/-/pipelines/1479158242

@junpeiz junpeiz self-requested a review October 2, 2024 17:39
@pytest.mark.parametrize(
"compute_unit, backend, frontend", itertools.product(compute_units, backends, frontends)
)
def test_cat_with_empty_tensors(self, compute_unit, backend, frontend):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Very nice! Will approve the PR after confirming green CI.

junpeiz
junpeiz previously approved these changes Oct 3, 2024
jakesabathia2
jakesabathia2 previously approved these changes Oct 3, 2024
coremltools/converters/mil/frontend/torch/ops.py Outdated Show resolved Hide resolved
@jirmasek jirmasek dismissed stale reviews from jakesabathia2 and junpeiz via 6780c1f October 4, 2024 15:07
@jirmasek
Copy link
Contributor Author

jirmasek commented Oct 4, 2024

@junpeiz junpeiz self-requested a review October 7, 2024 17:26
@jirmasek
Copy link
Contributor Author

jirmasek commented Oct 7, 2024

Copy link
Collaborator

@jakesabathia2 jakesabathia2 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 this amazing PR!

@junpeiz junpeiz merged commit 275c7e2 into apple:main Oct 8, 2024
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

Successfully merging this pull request may close these issues.

3 participants