Skip to content

feat: support more ops#5

Merged
InftyAI-Agent merged 6 commits into
InftyAI:mainfrom
kerthcet:feat/more-ops
Jul 21, 2026
Merged

feat: support more ops#5
InftyAI-Agent merged 6 commits into
InftyAI:mainfrom
kerthcet:feat/more-ops

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?


kerthcet added 2 commits July 21, 2026 15:08
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Copilot AI review requested due to automatic review settings July 21, 2026 15:15
@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

This PR expands the mlxcore::Array safe wrapper API to cover additional elementwise unary/binary operations and axis-specific reductions, aligning the Rust surface area more closely with the underlying MLX C API.

Changes:

  • Add new unary ops on Array: log, sin, cos, square, tanh.
  • Add new binary ops on Array: power, maximum, minimum.
  • Add axis-specific reductions (*_axes) via a new shared reduce_axes_op helper, plus unit tests covering the added ops.

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

@kerthcet

Copy link
Copy Markdown
Member Author

/kind feature

@InftyAI-Agent InftyAI-Agent added 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 Jul 21, 2026
@kerthcet
kerthcet requested a review from Copilot July 21, 2026 16:27

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 6 comments.

Comment thread crates/mlxcore/src/array.rs Outdated
Comment thread crates/mlxcore/src/array.rs
Comment thread crates/mlxcore/src/array.rs
Comment thread crates/mlxcore/src/array.rs
Comment thread crates/mlxcore/src/array.rs
Comment thread crates/mlxcore/src/array.rs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 21, 2026 21:44
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>

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.

Comments suppressed due to low confidence (1)

crates/mlxcore/src/array.rs:520

  • tanh is added as a new unary op but isn’t covered by the new more_unary_ops test (other new unary ops are). Adding at least one simple assertion (e.g., tanh(0)=0) would help prevent regressions in this binding.
        assert_eq!(
            b.negative(&s).unwrap().to_vec::<f32>(),
            vec![1.0, -2.0, 3.0]
        );
    }

Comment thread crates/mlxcore/src/array.rs
Comment thread crates/mlxcore/src/array.rs Outdated
Copilot AI review requested due to automatic review settings July 21, 2026 21:47

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 no new comments.

Comments suppressed due to low confidence (1)

crates/mlxcore/src/array.rs:343

  • The safety comment around axes_ptr is misleading: passing a null pointer does not make dereferencing safe. The key benefit here is avoiding passing a dangling pointer when axes.len() == 0; the C side still must not dereference the pointer when axes_num == 0. Updating the wording will prevent readers from assuming null makes dereferencing OK.
        // For an empty slice `as_ptr()` is non-null but dangling; pass an
        // explicit null pointer so the FFI call never hands C a bogus pointer
        // even if it were to dereference it with `axes_num == 0`.

Signed-off-by: kerthcet <kerthcet@gmail.com>
Copilot AI review requested due to automatic review settings July 21, 2026 21:53
@kerthcet

Copy link
Copy Markdown
Member Author

/lgtm

@InftyAI-Agent InftyAI-Agent added the lgtm Looks good to me, indicates that a PR is ready to be merged. label 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

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

Comments suppressed due to low confidence (1)

crates/mlxcore/src/array.rs:209

  • Rust doesn’t have a ** operator, so this doc comment can be misleading for Rust API consumers. Consider rephrasing to describe the operation without implying an available operator.
    /// Elementwise power: `self ** other`.

Comment on lines +184 to +187
/// Elementwise natural logarithm.
pub fn log(&self, stream: &Stream) -> Result<Array> {
self.unary_op(stream, sys::mlx_log)
}
@kerthcet

Copy link
Copy Markdown
Member Author

/hold

@InftyAI-Agent InftyAI-Agent added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 21, 2026
@kerthcet

Copy link
Copy Markdown
Member Author

/unhold

@InftyAI-Agent InftyAI-Agent removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 21, 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 b50b1e7 into InftyAI:main Jul 21, 2026
21 checks passed
@kerthcet
kerthcet deleted the feat/more-ops branch July 21, 2026 22:05
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