diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index c00c2c19..de86d599 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -103,7 +103,6 @@ jobs: shell: sh run: | xcodebuild -version - xcrun --show-sdk-build-version swift --version rm -rf ~/Library/Developer/Xcode/DerivedData/* xcodebuild build-for-testing -scheme mlx-swift-Package -destination 'platform=macOS' diff --git a/Source/MLX/Device.swift b/Source/MLX/Device.swift index 3a262c55..203c1e3f 100644 --- a/Source/MLX/Device.swift +++ b/Source/MLX/Device.swift @@ -173,8 +173,10 @@ public final class Device: @unchecked Sendable, Equatable { extension Device: CustomStringConvertible { public var description: String { var s = mlx_string_new() - mlx_device_tostring(&s, ctx) defer { mlx_string_free(s) } + _ = evalLock.withLock { + mlx_device_tostring(&s, ctx) + } return String(cString: mlx_string_data(s), encoding: .utf8)! } } diff --git a/Source/MLX/MLXArray.swift b/Source/MLX/MLXArray.swift index 44014aad..9e6148e0 100644 --- a/Source/MLX/MLXArray.swift +++ b/Source/MLX/MLXArray.swift @@ -616,8 +616,10 @@ extension MLXArray: Updatable, Evaluatable { extension MLXArray: CustomStringConvertible { public var description: String { var s = mlx_string_new() - mlx_array_tostring(&s, ctx) defer { mlx_string_free(s) } + _ = evalLock.withLock { + mlx_array_tostring(&s, ctx) + } return String(cString: mlx_string_data(s), encoding: .utf8)! } } diff --git a/Source/MLX/Stream.swift b/Source/MLX/Stream.swift index c276d6de..6f2d2aa4 100644 --- a/Source/MLX/Stream.swift +++ b/Source/MLX/Stream.swift @@ -161,8 +161,10 @@ public final class Stream: @unchecked Sendable, Equatable { extension Stream: CustomStringConvertible { public var description: String { var s = mlx_string_new() - mlx_stream_tostring(&s, ctx) defer { mlx_string_free(s) } + _ = evalLock.withLock { + mlx_stream_tostring(&s, ctx) + } return String(cString: mlx_string_data(s), encoding: .utf8)! } }