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
2 changes: 1 addition & 1 deletion Source/MLX/Stream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public struct StreamOrDevice: Sendable, CustomStringConvertible, Equatable {
public static let gpu = device(.gpu)

public static func stream(_ stream: Stream) -> StreamOrDevice {
StreamOrDevice(Device.defaultStream())
StreamOrDevice(stream)
}

/// Internal context -- used with Cmlx calls.
Expand Down
10 changes: 10 additions & 0 deletions Tests/MLXTests/StreamTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ class StreamTests: XCTestCase {
print("here")
}

func testStreamOrDeviceStreamUsesGivenStream() {
// StreamOrDevice.stream(_:) used to ignore its argument and return
// the default stream instead
let stream = Stream(.cpu)
XCTAssertEqual(StreamOrDevice.stream(stream).stream, stream)

XCTAssertEqual(StreamOrDevice.stream(.cpu).stream, Stream.cpu)
XCTAssertEqual(StreamOrDevice.stream(.gpu).stream, Stream.gpu)
}

func disabledTestCreateStream() {
// see https://github.com/ml-explore/mlx/issues/2118
for _ in 1 ..< 10000 {
Expand Down
Loading