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)
58
58
set (TARGET whisper.coreml )
59
59
60
60
add_library (${TARGET}
61
+ coreml/whisper-compat.m
61
62
coreml/whisper-encoder.h
62
63
coreml/whisper-encoder.mm
63
64
coreml/whisper-encoder-impl.h
@@ -76,6 +77,7 @@ if (WHISPER_COREML)
76
77
COMPILE_FLAGS "-fobjc-arc"
77
78
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
78
79
)
80
+
79
81
set_target_properties (${TARGET} PROPERTIES FOLDER "libs" )
80
82
endif ()
81
83
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 8
8
#error This file must be compiled with automatic reference counting enabled (-fobjc-arc)
9
9
#endif
10
10
11
+ #import " whisper-compat.h"
11
12
#import " whisper-decoder-impl.h"
12
13
13
14
@implementation whisper_decoder_implInput
Original file line number Diff line number Diff line change 8
8
#error This file must be compiled with automatic reference counting enabled (-fobjc-arc)
9
9
#endif
10
10
11
+ #import " whisper-compat.h"
11
12
#import " whisper-encoder-impl.h"
12
13
13
14
@implementation whisper_encoder_implInput
You can’t perform that action at this time.
0 commit comments