Skip to content

Fix diff-train by removing Float16 conformance #11079

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

Merged
merged 1 commit into from
May 23, 2025
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
3 changes: 0 additions & 3 deletions extension/apple/ExecuTorch/Exported/ExecuTorch+Tensor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ extension Int32: Scalar { static var dataType: DataType { .int } }
extension Int64: Scalar { static var dataType: DataType { .long } }
@available(*, deprecated, message: "This API is experimental.")
extension Int: Scalar { static var dataType: DataType { .long } }
@available(macOS 11.0, *)
@available(*, deprecated, message: "This API is experimental.")
extension Float16: Scalar { static var dataType: DataType { .half } }
@available(*, deprecated, message: "This API is experimental.")
extension Float: Scalar { static var dataType: DataType { .float } }
@available(*, deprecated, message: "This API is experimental.")
Expand Down
24 changes: 0 additions & 24 deletions extension/apple/ExecuTorch/__tests__/TensorTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,30 +172,6 @@ class TensorTest: XCTestCase {
}
}

func testWithUnsafeBytesFloat16() throws {
var data: [Float16] = [1, 2, 3, 4, 5, 6]
let tensor = data.withUnsafeMutableBytes {
Tensor(bytesNoCopy: $0.baseAddress!, shape: [6], dataType: .half)
}
let array: [Float16] = try tensor.withUnsafeBytes { Array($0) }
XCTAssertEqual(array, data)
}

func testWithUnsafeMutableBytesFloat16() throws {
var data: [Float16] = [1, 2, 3, 4]
let tensor = data.withUnsafeMutableBytes { buffer in
Tensor(bytes: buffer.baseAddress!, shape: [4], dataType: .half)
}
try tensor.withUnsafeMutableBytes { (buffer: UnsafeMutableBufferPointer<Float16>) in
for i in buffer.indices {
buffer[i] *= 2
}
}
try tensor.withUnsafeBytes { buffer in
XCTAssertEqual(Array(buffer), data.map { $0 * 2 })
}
}

func testInitWithTensor() {
var data: [Int] = [10, 20, 30, 40]
let tensor1 = data.withUnsafeMutableBytes {
Expand Down
Loading