xref: /aosp_15_r20/external/executorch/backends/apple/coreml/runtime/delegate/model_event_logger.h (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1 //
2 // model_event_logger.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 #pragma once
9 
10 #import <CoreML/CoreML.h>
11 
12 @class ETCoreMLModelStructurePath;
13 @class ETCoreMLOperationProfilingInfo;
14 
15 namespace executorchcoreml {
16 
17 /// An abstract class for logging model events (profiling/debugging) .
18 class ModelEventLogger {
19 public:
ModelEventLogger()20     inline ModelEventLogger() noexcept { }
21     virtual ~ModelEventLogger() noexcept = default;
22 
23     /// Must log profiling infos.
24     ///
25     /// @param op_path_to_profiling_info_map A dictionary with the operation path as the key and operation's profiling
26     /// info as the value.
27     /// @param op_path_to_debug_symbol_name_map A dictionary with the operation path as the key and the symbol name as
28     /// the value. The symbol name is the delegate handle.
29     virtual void log_profiling_infos(
30         NSDictionary<ETCoreMLModelStructurePath*, ETCoreMLOperationProfilingInfo*>* op_path_to_profiling_info_map,
31         NSDictionary<ETCoreMLModelStructurePath*, NSString*>* op_path_to_debug_symbol_name_map) const noexcept = 0;
32 
33     /// Must log intermediate tensors.
34     ///
35     /// @param op_path_to_value_map A dictionary with the operation path as the key and the operation's value as the
36     /// value.
37     /// @param op_path_to_debug_symbol_name_map A dictionary with the operation path as the key and the debug symbol
38     /// name as the value.
39     virtual void log_intermediate_tensors(
40         NSDictionary<ETCoreMLModelStructurePath*, MLMultiArray*>* op_path_to_value_map,
41         NSDictionary<ETCoreMLModelStructurePath*, NSString*>* op_path_to_debug_symbol_name_map) const noexcept = 0;
42 };
43 }
44