xref: /aosp_15_r20/external/executorch/backends/apple/coreml/runtime/sdk/ETCoreMLModelAnalyzer.h (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1 //
2 // ETCoreMLModelAnalyzer.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 #import "ETCoreMLModelExecutor.h"
11 
12 namespace executorchcoreml {
13 struct ModelMetadata;
14 }
15 
16 @class ETCoreMLAsset;
17 @class ETCoreMLAssetManager;
18 @class ETCoreMLModelDebugInfo;
19 @class ETCoreMLModelStructurePath;
20 @protocol ETCoreMLModelEventLogger;
21 
22 NS_ASSUME_NONNULL_BEGIN
23 
24 __attribute__((objc_subclassing_restricted))
25 /// A class responsible for executing a model, it also logs model events (profiling and debugging ).
26 @interface ETCoreMLModelAnalyzer : NSObject<ETCoreMLModelExecutor>
27 
28 - (instancetype)init NS_UNAVAILABLE;
29 
30 + (instancetype)new NS_UNAVAILABLE;
31 
32 /// Constructs an `ETCoreMLModelAnalyzer` instance.
33 ///
34 /// @param compiledModelAsset The compiled model asset (mlmodelc).
35 /// @param modelAsset The model asset (mlpackage).
36 /// @param modelDebugInfo The model debug info.
37 /// @param metadata The model metadata.
38 /// @param configuration The model configuration.
39 /// @param assetManager The asset manager used to manage storage of compiled models.
40 /// @param error   On failure, error is filled with the failure information.
41 - (nullable instancetype)initWithCompiledModelAsset:(ETCoreMLAsset*)compiledModelAsset
42                                          modelAsset:(nullable ETCoreMLAsset*)modelAsset
43                                      modelDebugInfo:(nullable ETCoreMLModelDebugInfo*)modelDebugInfo
44                                            metadata:(const executorchcoreml::ModelMetadata&)metadata
45                                       configuration:(MLModelConfiguration*)configuration
46                                        assetManager:(ETCoreMLAssetManager*)assetManager
47                                               error:(NSError* __autoreleasing*)error NS_DESIGNATED_INITIALIZER;
48 /// The model.
49 @property (readonly, strong, nonatomic) ETCoreMLModel* model;
50 
51 /// If set to `YES` then output backing are ignored.
52 @property (readwrite, atomic) BOOL ignoreOutputBackings;
53 
54 @end
55 
56 NS_ASSUME_NONNULL_END
57