File tree Expand file tree Collapse file tree 5 files changed +42
-0
lines changed Expand file tree Collapse file tree 5 files changed +42
-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/MLModel+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 " MLModel+Compat.h"
2+
3+ @implementation MLModel (Compat)
4+
5+ #if !defined(MAC_OS_X_VERSION_14_00) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_14_00
6+
7+ - (void ) predictionFromFeatures : (id <MLFeatureProvider>) input
8+ completionHandler : (void (^)(id <MLFeatureProvider> output, NSError * error)) completionHandler {
9+ [NSOperationQueue .mainQueue addOperationWithBlock: ^{
10+ NSError *error = nil ;
11+ id <MLFeatureProvider> prediction = [self predictionFromFeatures: input error: &error];
12+ completionHandler (prediction, error);
13+ }];
14+ }
15+
16+ - (void ) predictionFromFeatures : (id <MLFeatureProvider>) input
17+ options : (MLPredictionOptions *) options
18+ completionHandler : (void (^)(id <MLFeatureProvider> output, NSError * error)) completionHandler {
19+ [NSOperationQueue .mainQueue addOperationWithBlock: ^{
20+ NSError *error = nil ;
21+ id <MLFeatureProvider> prediction = [self predictionFromFeatures: input options: options error: &error];
22+ completionHandler (prediction, error);
23+ }];
24+ }
25+
26+ #endif
27+
28+ @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 " MLModel+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 " MLModel+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