5
5
//
6
6
// Please refer to the license found in the LICENSE file in the root directory of the source tree.
7
7
8
- #import < ETCoreMLAsset.h>
9
- #import < ETCoreMLAssetManager.h>
10
- #import < ETCoreMLDefaultModelExecutor.h>
11
- #import < ETCoreMLLogging.h>
12
- #import < ETCoreMLModel.h>
13
- #import < ETCoreMLModelAnalyzer.h>
14
- #import < ETCoreMLModelLoader.h>
15
- #import < ETCoreMLModelStructurePath.h>
16
- #import < ETCoreMLModelDebugger.h>
17
- #import < ETCoreMLModelProfiler.h>
18
- #import < ETCoreMLStrings.h>
19
- #import < model_logging_options.h>
20
- #import < model_event_logger.h>
21
- #import < model_metadata.h>
22
- #import < model_package_info.h>
23
- #import < objc_safe_cast.h>
8
+ #import " ETCoreMLModelAnalyzer.h"
9
+
10
+ #import " ETCoreMLAsset.h"
11
+ #import " ETCoreMLAssetManager.h"
12
+ #import " ETCoreMLDefaultModelExecutor.h"
13
+ #import " ETCoreMLLogging.h"
14
+ #import " ETCoreMLModel.h"
15
+ #import " ETCoreMLModelLoader.h"
16
+ #import " ETCoreMLModelStructurePath.h"
17
+ #import " ETCoreMLModelDebugInfo.h"
18
+ #import " ETCoreMLModelDebugger.h"
19
+ #import " ETCoreMLModelProfiler.h"
20
+ #import " ETCoreMLStrings.h"
21
+ #import " model_logging_options.h"
22
+ #import " model_event_logger.h"
23
+ #import " model_metadata.h"
24
+ #import " model_package_info.h"
25
+ #import " objc_safe_cast.h"
24
26
25
27
namespace {
26
28
using namespace executorchcoreml ;
@@ -34,7 +36,7 @@ @interface ETCoreMLModelAnalyzer ()
34
36
@property (strong , nonatomic , nullable ) ETCoreMLModelProfiler *profiler;
35
37
@property (strong , nonatomic , nullable ) ETCoreMLModelDebugger *debugger;
36
38
@property (strong , nonatomic , nullable ) id <ETCoreMLModelExecutor> executor;
37
- @property (readonly , copy , nonatomic , nullable ) NSDictionary <ETCoreMLModelStructurePath *, NSString *> *operationPathToDebugSymbolMap ;
39
+ @property (readonly , copy , nonatomic , nullable ) ETCoreMLModelDebugInfo *modelDebugInfo ;
38
40
@property (readonly , strong , nonatomic ) MLModelConfiguration *configuration;
39
41
40
42
@end
@@ -43,8 +45,8 @@ @implementation ETCoreMLModelAnalyzer
43
45
44
46
- (nullable instancetype )initWithCompiledModelAsset : (ETCoreMLAsset *)compiledModelAsset
45
47
modelAsset : (nullable ETCoreMLAsset *)modelAsset
48
+ modelDebugInfo : (nullable ETCoreMLModelDebugInfo *)modelDebugInfo
46
49
metadata : (const executorchcoreml::ModelMetadata&)metadata
47
- operationPathToDebugSymbolMap : (nullable NSDictionary <ETCoreMLModelStructurePath *, NSString *> *)operationPathToDebugSymbolMap
48
50
configuration : (MLModelConfiguration *)configuration
49
51
assetManager : (ETCoreMLAssetManager *)assetManager
50
52
error : (NSError * __autoreleasing *)error {
@@ -72,9 +74,9 @@ - (nullable instancetype)initWithCompiledModelAsset:(ETCoreMLAsset *)compiledMod
72
74
if (self) {
73
75
_model = model;
74
76
_modelAsset = modelAsset;
77
+ _modelDebugInfo = modelDebugInfo;
75
78
_assetManager = assetManager;
76
79
_configuration = configuration;
77
- _operationPathToDebugSymbolMap = operationPathToDebugSymbolMap;
78
80
_executor = [[ETCoreMLDefaultModelExecutor alloc ] initWithModel: model];
79
81
}
80
82
@@ -113,7 +115,7 @@ - (nullable instancetype)initWithCompiledModelAsset:(ETCoreMLAsset *)compiledMod
113
115
return nil ;
114
116
}
115
117
116
- eventLogger->log_profiling_infos (profilingInfos, self.operationPathToDebugSymbolMap );
118
+ eventLogger->log_profiling_infos (profilingInfos, self.modelDebugInfo . pathToDebugSymbolMap );
117
119
return modelOutputs;
118
120
}
119
121
@@ -131,6 +133,7 @@ - (nullable instancetype)initWithCompiledModelAsset:(ETCoreMLAsset *)compiledMod
131
133
132
134
if (!self.debugger ) {
133
135
self.debugger = [[ETCoreMLModelDebugger alloc ] initWithModelAsset: self .modelAsset
136
+ modelDebugInfo: self .modelDebugInfo
134
137
outputNames: self .model.orderedOutputNames
135
138
configuration: self .configuration
136
139
assetManager: self .assetManager
@@ -143,6 +146,7 @@ - (nullable instancetype)initWithCompiledModelAsset:(ETCoreMLAsset *)compiledMod
143
146
144
147
NSArray <MLMultiArray *> *modelOutputs = nil ;
145
148
NSArray <ETCoreMLModelStructurePath *> *operationPaths = self.debugger .operationPaths ;
149
+ NSDictionary <ETCoreMLModelStructurePath *, NSString *> *operationPathToDebugSymbolMap = self.debugger .operationPathToDebugSymbolMap ;
146
150
NSInteger n = operationPaths.count /MAX_MODEL_OUTPUTS_COUNT + (operationPaths.count % MAX_MODEL_OUTPUTS_COUNT == 0 ? 0 : 1 );
147
151
for (NSInteger i = 0 ; i < n; i++) {
148
152
@autoreleasepool {
@@ -157,7 +161,7 @@ - (nullable instancetype)initWithCompiledModelAsset:(ETCoreMLAsset *)compiledMod
157
161
}
158
162
159
163
if (outputs.count > 0 ) {
160
- eventLogger->log_intermediate_tensors (outputs, self. operationPathToDebugSymbolMap );
164
+ eventLogger->log_intermediate_tensors (outputs, operationPathToDebugSymbolMap);
161
165
}
162
166
}
163
167
}
0 commit comments