File tree Expand file tree Collapse file tree 5 files changed +49
-0
lines changed Expand file tree Collapse file tree 5 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ if (WHISPER_COREML)
5858 set (TARGET whisper.coreml)
5959
6060 add_library (${TARGET}
61+ coreml/whisper-compat.m
6162 coreml/whisper-encoder.h
6263 coreml/whisper-encoder.mm
6364 coreml/whisper-encoder-impl.h
@@ -76,6 +77,7 @@ if (WHISPER_COREML)
7677 COMPILE_FLAGS "-fobjc-arc"
7778 XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
7879 )
80+
7981 set_target_properties (${TARGET} PROPERTIES FOLDER "libs" )
8082endif ()
8183
Original file line number Diff line number Diff line change 1+ #import < CoreML/CoreML.h>
2+
3+ @interface MLModel (Compat)
4+ - (void ) predictionFromFeatures : (id <MLFeatureProvider>) input
5+ completionHandler : (void (^)(id <MLFeatureProvider> output, NSError * error)) completionHandler ;
6+
7+ - (void ) predictionFromFeatures : (id <MLFeatureProvider>) input
8+ options : (MLPredictionOptions *) options
9+ completionHandler : (void (^)(id <MLFeatureProvider> output, NSError * error)) completionHandler ;
10+ @end
Original file line number Diff line number Diff line change 1+ #import " whisper-compat.h"
2+ #import < Foundation/Foundation.h>
3+
4+ @implementation MLModel (Compat)
5+
6+ #if !defined(MAC_OS_X_VERSION_14_00) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_14_00
7+
8+ - (void ) predictionFromFeatures : (id <MLFeatureProvider>) input
9+ completionHandler : (void (^)(id <MLFeatureProvider> output, NSError * error)) completionHandler {
10+ [NSOperationQueue .new addOperationWithBlock: ^{
11+ NSError *error = nil ;
12+ id <MLFeatureProvider> prediction = [self predictionFromFeatures: input error: &error];
13+
14+ [NSOperationQueue .mainQueue addOperationWithBlock: ^{
15+ completionHandler (prediction, error);
16+ }];
17+ }];
18+ }
19+
20+ - (void ) predictionFromFeatures : (id <MLFeatureProvider>) input
21+ options : (MLPredictionOptions *) options
22+ completionHandler : (void (^)(id <MLFeatureProvider> output, NSError * error)) completionHandler {
23+ [NSOperationQueue .new addOperationWithBlock: ^{
24+ NSError *error = nil ;
25+ id <MLFeatureProvider> prediction = [self predictionFromFeatures: input options: options error: &error];
26+
27+ [NSOperationQueue .mainQueue addOperationWithBlock: ^{
28+ completionHandler (prediction, error);
29+ }];
30+ }];
31+ }
32+
33+ #endif
34+
35+ @end
Original file line number Diff line number Diff line change 88#error This file must be compiled with automatic reference counting enabled (-fobjc-arc)
99#endif
1010
11+ #import " whisper-compat.h"
1112#import " whisper-decoder-impl.h"
1213
1314@implementation whisper_decoder_implInput
Original file line number Diff line number Diff line change 88#error This file must be compiled with automatic reference counting enabled (-fobjc-arc)
99#endif
1010
11+ #import " whisper-compat.h"
1112#import " whisper-encoder-impl.h"
1213
1314@implementation whisper_encoder_implInput
You can’t perform that action at this time.
0 commit comments