Skip to content

Commit e6b6dd4

Browse files
committed
Allow archiving for Mac (#121)
SPM dependencies are always compiled for the standard architectures, but Float16 is not available for `x86_64`. Thanks @joshnewnham for the workaround 🙌
1 parent 9ba8173 commit e6b6dd4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/Models/LanguageModel.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,22 @@ public class LanguageModelWithStatefulKVCache: LanguageModel {
385385
Keys.inputIds: inputIds,
386386
]
387387
if isRequiringAttentionMask {
388+
#if !((os(macOS) || (macCatalyst)) && arch(x86_64))
388389
// TODO: Infer scalar type from cache or model I/O descriptors
389390
let attentionMask = MLTensor(zeros: [1, 1, 1, tokenCount + 1], scalarType: Float16.self)
390391
inputDictionary[Keys.attentionMask] = attentionMask
392+
#else
393+
fatalError()
394+
#endif
391395
}
392396
if isRequiringCausalMask {
397+
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
393398
// TODO: Infer scalar type from cache or model I/O descriptors
394399
let causalMask = MLTensor(zeros: [1, 1, 1, tokenCount + 1], scalarType: Float16.self)
395400
inputDictionary[Keys.causalMask] = causalMask
401+
#else
402+
fatalError()
403+
#endif
396404
}
397405
let outputs = try! await model.prediction(from: inputDictionary, using: state)
398406

0 commit comments

Comments
 (0)