Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Source/MLX/ErrorHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ private let errorHandler: ErrorHandler = {
return ErrorHandler()
}()

/// Ensure that the error handler is installed.
func initError() {
_ = errorHandler
}

/// Forward the error to the `ErrorHandler` singleton. See `errorHandler` (above) for how this is
/// installed.
private func errorHandlerTrampoline(message: UnsafePointer<CChar>?, data: UnsafeMutableRawPointer?)
Expand Down
3 changes: 3 additions & 0 deletions Source/MLX/MLXArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public final class MLXArray {
///
/// This initializer is for `Cmlx` interoperation.
public init(_ ctx: consuming mlx_array) {
// We don't have lifecycle control over the MLX system but all interesting
// paths will come through here -- make sure the error handler is installed.
initError()
self.ctx = ctx
}

Expand Down