implement Convolution::output_shape#2601
Merged
awni merged 1 commit intoml-explore:mainfrom Sep 22, 2025
Merged
Conversation
awni
reviewed
Sep 18, 2025
mlx/conv_shape.h
Outdated
| @@ -0,0 +1,121 @@ | |||
| // Copyright © 2025 Apple Inc. | |||
Member
There was a problem hiding this comment.
We don't want a new file for this. Instead you can make it static on the Convolution primitive and then just use it in the ops.
awni
reviewed
Sep 18, 2025
mlx/primitives.cpp
Outdated
Comment on lines
+1465
to
+1476
| auto expand = [spatial_dims](const std::vector<int>& v, int def) { | ||
| if (v.empty()) { | ||
| return std::vector<int>(spatial_dims, def); | ||
| } | ||
| if (v.size() == 1) { | ||
| return std::vector<int>(spatial_dims, v[0]); | ||
| } | ||
| if (v.size() == spatial_dims) { | ||
| return v; | ||
| } | ||
| throw std::invalid_argument("Convolution param rank mismatch"); | ||
| }; |
Member
There was a problem hiding this comment.
I think these parameters should already be expanded once they are in the primitive right?
- pull conv_out_shape out for re-use - add Conv::output_shape - add e2e python tests confirming shapeless=True support and correctness Updates ml-explore#2599
fb65912 to
4a7d6ad
Compare
Contributor
Author
|
Great feedback. Thanks! Fixed and re-tested and pushed a new commit. PTAL. |
faisalmemon
pushed a commit
to faisalmemon/mlx
that referenced
this pull request
Oct 30, 2025
- pull conv_out_shape out for re-use - add Conv::output_shape - add e2e python tests confirming shapeless=True support and correctness Updates ml-explore#2599
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Implement
Convolution::output_shapeso that convolutions can be used with shapeless function exports.Please review carefully: My C++ is not super strong, and I'm new to mlx.
The code in mlx/conv_shape.h is 100% code movement from mlx/ops.cpp, no changes aside from marking
conv_out_shapeasinline.Updates #2599
Checklist
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes