xref: /aosp_15_r20/external/executorch/backends/apple/coreml/runtime/delegate/ETCoreMLModelExecutor.h (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1 //
2 // ETCoreMLModelExecutor.h
3 //
4 // Copyright © 2024 Apple Inc. All rights reserved.
5 //
6 // Please refer to the license found in the LICENSE file in the root directory of the source tree.
7 
8 #import <CoreML/CoreML.h>
9 
10 @class ETCoreMLModel;
11 
12 namespace executorchcoreml {
13 struct ModelLoggingOptions;
14 class ModelEventLogger;
15 }
16 
17 NS_ASSUME_NONNULL_BEGIN
18 /// A protocol that an object must adopt for hooking into `ETCoreMLModelManager` as a model executor.
19 @protocol ETCoreMLModelExecutor <NSObject>
20 
21 /// Executes the model with the given inputs and returns the outputs.
22 ///
23 /// @param inputs The inputs to the model.
24 /// @param predictionOptions The prediction options.
25 /// @param loggingOptions The logging options.
26 /// @param eventLogger The event logger.
27 /// @param error   On failure, error is filled with the failure information.
28 - (nullable NSArray<MLMultiArray*>*)executeModelWithInputs:(id<MLFeatureProvider>)inputs
29                                          predictionOptions:(MLPredictionOptions*)predictionOptions
30                                             loggingOptions:(const executorchcoreml::ModelLoggingOptions&)loggingOptions
31                                                eventLogger:
32                                                    (const executorchcoreml::ModelEventLogger* _Nullable)eventLogger
33                                                      error:(NSError* __autoreleasing*)error;
34 
35 /// The model.
36 @property (readonly, strong, nonatomic) ETCoreMLModel* model;
37 
38 /// If set to `YES` then output backing are ignored.
39 @property (readwrite, atomic) BOOL ignoreOutputBackings;
40 
41 
42 @end
43 
44 NS_ASSUME_NONNULL_END
45