Skip to main content

MLX array supercharged

Project description

MLX eXtended

mlx.core.array supercharged.

Usage

Installation:

  • pip install mlxx
  • uv add mlxx

After importing mlx, do this

import mlx.core as mx
# this will monkey patch `mlx.core.array` class with more convenient methods
import mlxx as _ 

Then you can use some methods like allclose

a = mx.array([1, 2, 3], dtype=mx.float32)
b = mx.array([1, 2, 3], dtype=mx.float32)
print(a.allclose(b))
print(a.inner(b))

Available Convenient Methods

Comparison Operations

  • allclose(b, rtol=1e-05, atol=1e-08, equal_nan=False): Check if arrays are close within tolerance
  • isclose(b, rtol=1e-05, atol=1e-08, equal_nan=False): Element-wise comparison within tolerance
  • array_equal(b, equal_nan=False): Check if arrays are exactly equal

Logical Operations

  • logical_and(b): Element-wise logical AND
  • logical_or(b): Element-wise logical OR
  • logical_xor(b): Element-wise logical XOR
  • logical_not(): Element-wise logical NOT

Binary Operations

  • binary_maximum(b): Element-wise maximum
  • binary_minimum(b): Element-wise minimum
  • power(exponent): Element-wise power
  • matmul(b): Matrix multiplication
  • inner(b): Inner product

Trigonometric Functions

  • arccos(): Inverse cosine
  • arccosh(): Inverse hyperbolic cosine
  • arcsin(): Inverse sine
  • arcsinh(): Inverse hyperbolic sine
  • arctan(): Inverse tangent
  • arctanh(): Inverse hyperbolic tangent
  • cosh(): Hyperbolic cosine
  • sinh(): Hyperbolic sine
  • tan(): Tangent
  • tanh(): Hyperbolic tangent

Mathematical Functions

  • ceil(): Ceiling function
  • floor(): Floor function
  • degrees(): Convert radians to degrees
  • radians(): Convert degrees to radians
  • erf(): Error function
  • erfinv(): Inverse error function
  • expm1(): exp(x) - 1
  • sigmoid(): Sigmoid function
  • sign(): Sign function

Complex Number Operations

  • imag(): Imaginary part
  • real(): Real part

Infinity and NaN Checks

  • isfinite(): Check for finite values
  • isinf(): Check for infinite values
  • isnan(): Check for NaN values
  • isneginf(): Check for negative infinity
  • isposinf(): Check for positive infinity

Other Operations

  • negative(): Element-wise negation
  • stop_gradient(): Stop gradient computation
  • permute(): Alias for transpose

Note: All methods support an optional stream parameter for controlling computation streams.

Contributing

Feel free to make PRs!

Setup Dev Env

  1. Run uv sync
  2. Run pre-commit install, or uv run pre-commit install if your shell doesn't autodetect venv

LICENSE

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlxx-0.1.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlxx-0.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file mlxx-0.1.1.tar.gz.

File metadata

  • Download URL: mlxx-0.1.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.3

File hashes

Hashes for mlxx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 69eead7c560c5c79db587a24815f04ec9879a1c9d8f5547854434a2b5214d9bf
MD5 e93e9ae110754cdfcbe7e3a8266cb6bc
BLAKE2b-256 57e47d874abfbae88f306fd5e8eaadf75f1cb5feb1703d2dcee2299107b2b2aa

See more details on using hashes here.

File details

Details for the file mlxx-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mlxx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.3

File hashes

Hashes for mlxx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76f3b70032484d1ce2851f49b6ce137c811fe79fe3c1c4378102e3389752c233
MD5 896a5c07ac224060bab395285c52e177
BLAKE2b-256 7eaebc2670e6fcfdafbd23e39c19984fd69a25830a762ce2f5b238f6085d813d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page