Skip to content

Commit

Permalink
Fixed Conformance of 'Float16' warning (#58)
Browse files Browse the repository at this point in the history
* fixed warnings

* removed fixme
  • Loading branch information
jkrukowski authored Mar 7, 2024
1 parent 880f95e commit 20c9001
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Sources/WhisperKit/Core/Models.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
// For licensing see accompanying LICENSE.md file.
// Copyright © 2024 Argmax, Inc. All rights reserved.

import Accelerate
import CoreML
import Hub
import NaturalLanguage
import Tokenizers

#if os(watchOS) || arch(arm64)
@available(macOS 13, iOS 16, watchOS 10, visionOS 1, *)
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
public typealias FloatType = Float16
#else
public typealias FloatType = Float
#endif

#if (os(macOS) || targetEnvironment(macCatalyst)) && arch(arm64)
extension Float16: BNNSScalar {}
#endif

// MARK: - CoreML

public protocol WhisperMLModel {
Expand Down
2 changes: 1 addition & 1 deletion Sources/WhisperKit/Core/TokenSampler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class GreedyTokenSampler: TokenSampling {

let logitsDescriptor = BNNSNDArrayDescriptor(
data: logitsRawPointer,
scalarType: FloatType.self, // FIXME: Float16 here breaks in swift 6
scalarType: FloatType.self,
shape: .vector(logits.count, stride: 1)
)!

Expand Down

0 comments on commit 20c9001

Please sign in to comment.