Skip to content

feat: add shape manipulation ops on Array - #6

Merged
InftyAI-Agent merged 4 commits into
InftyAI:mainfrom
kerthcet:feat/shape-manipulation
Aug 23, 2026
Merged

feat: add shape manipulation ops on Array#6
InftyAI-Agent merged 4 commits into
InftyAI:mainfrom
kerthcet:feat/shape-manipulation

Conversation

@kerthcet

Copy link
Copy Markdown
Member

What this PR does / why we need it

Which issue(s) this PR fixes

Fixes #

Special notes for your reviewer

Does this PR introduce a user-facing change?


Signed-off-by: kerthcet <kerthcet@gmail.com>
Copilot AI lite review requested due to automatic review settings July 21, 2026 23:12
@InftyAI-Agent InftyAI-Agent added needs-triage Indicates an issue or PR lacks a label and requires one. needs-priority Indicates a PR lacks a label and requires one. do-not-merge/needs-kind Indicates a PR lacks a label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds shape-manipulation operations to mlxcore::Array and updates host extraction (to_vec) to correctly handle non-contiguous views by materializing a row-contiguous buffer first. This expands the safe Rust surface area over MLX-C’s shape/view operators and makes to_vec semantics consistent for transposed/broadcasted arrays.

Changes:

  • Update Array::to_vec to materialize a row-contiguous copy before reading via raw data pointers (fixing transpose/broadcast cases).
  • Add shape/view ops on Array: contiguous, reshape, broadcast_to, transpose, squeeze, expand_dims.
  • Add unit tests covering reshape/transpose/broadcast/squeeze+expand_dims.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/mlxcore/src/array.rs Outdated
Comment thread crates/mlxcore/src/array.rs
Signed-off-by: kerthcet <kerthcet@gmail.com>
Copilot AI review requested due to automatic review settings July 22, 2026 07:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread crates/mlxcore/src/array.rs
Comment thread crates/mlxcore/src/array.rs Outdated
kerthcet and others added 2 commits July 23, 2026 19:23
Add strides()/is_row_contiguous() computed from public shape+strides,
and split to_vec into a fast path (direct bulk read for row-contiguous
arrays, the common case) and a slow path (materialize a contiguous copy
only for strided/broadcast views). Shared read_buffer helper.

Avoids an extra FFI op + CPU-stream copy on every to_vec call.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Copilot AI review requested due to automatic review settings August 23, 2026 22:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@kerthcet

Copy link
Copy Markdown
Member Author

/lgtm
/kind feature

@InftyAI-Agent InftyAI-Agent added lgtm Looks good to me, indicates that a PR is ready to be merged. feature Categorizes issue or PR as related to a new feature. and removed do-not-merge/needs-kind Indicates a PR lacks a label and requires one. labels Aug 23, 2026

@InftyAI-Agent InftyAI-Agent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved: PR has both lgtm and approved labels

@InftyAI-Agent
InftyAI-Agent merged commit 1950710 into InftyAI:main Aug 23, 2026
19 of 21 checks passed
@kerthcet
kerthcet deleted the feat/shape-manipulation branch August 23, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. feature Categorizes issue or PR as related to a new feature. lgtm Looks good to me, indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a label and requires one. needs-triage Indicates an issue or PR lacks a label and requires one.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants