-
Notifications
You must be signed in to change notification settings - Fork 111
Update mlx-c to 0.1.2 #204
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
Conversation
See also #206 -- I wasn't done with it but I set up a PR with what I have. This may go together |
Co-authored-by: DavidKoski <46639364+davidkoski@users.noreply.github.com>
Source/MLX/MLXArray+Init.swift
Outdated
public convenience init<T: HasDType>(_ value: T) { | ||
let floatMax = Double(Float.greatestFiniteMagnitude) | ||
let doubleValue = value as? Double | ||
if doubleValue != nil && doubleValue! < floatMax && doubleValue! > -floatMax { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is to convert a scalar to float64
only if it lies outside the range representable for float32
. We could also just always cast to float32
and let the user do MLXArray(0.1, dtype: .float64)
if they want a float64.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be better as init(_ value: Double)
-- otherwise this logic is use for bools, ints, etc. It should still work, but I think specializing it to Double
expresses the intent better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good I'll change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remembered why I put it here:
When you initialize a MLXArray
from a range e.g. in
let a = MLXRandom.uniform(0.0 ..< 1.0, [4, 10, 12, 4])
You're redirected to this initialization rather than init(_ value: Double)
.
Do you know if there's a better way to overload in that case as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good, thank you!
Update mlx-c to 0.1.2 and mlx to 0.23.1
I added a few of the new methods:
MLXLinalg.lu
MLXLinalg.lu_factor
MLXLinalg.solve
MLXLinalg.solve_triangular
flatten
unflatten
kron