Skip to content

Commit 88a7415

Browse files
Gasoonjiafacebook-github-bot
authored andcommitted
Introduce event_tracer_filter_base class (#9467)
Summary: This update introduces event_tracer_filter_base class as the base class for delegation intermediate output filtering. Details can be found in #9260 Reviewed By: tarun292 Differential Revision: D71569728
1 parent 1a9a59b commit 88a7415

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

runtime/core/event_tracer.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <executorch/runtime/core/array_ref.h>
1010
#include <executorch/runtime/core/evalue.h>
11+
#include <executorch/runtime/core/result.h>
1112
#include <executorch/runtime/platform/platform.h>
1213
#include <stdlib.h>
1314
#include <cstdint>
@@ -67,6 +68,42 @@ enum class EventTracerDebugLogLevel {
6768
kIntermediateOutputs,
6869
};
6970

71+
/**
72+
* EventTracerFilterBase is an abstract base class that provides an interface
73+
* for filtering events based on their name or delegate debug index.
74+
* Derived classes should implement the filter method to define specific
75+
* filtering logic.
76+
*/
77+
class EventTracerFilterBase {
78+
public:
79+
/**
80+
* Filters events based on the given name or delegate debug index.
81+
*
82+
* Note that only one of either the name or delegate_debug_index should be passed in.
83+
*
84+
* @param[in] name A pointer to a string representing the `name` of the
85+
* event. If `delegate_debug_index` is not set to kUnsetDebugHandle, `name` should
86+
* be set to nullptr.
87+
*
88+
* @param[in] delegate_debug_index A DebugHandle representing the debug index
89+
* of the delegate. If `name` is not nullptr, this should be set to
90+
* kUnsetDebugHandle.
91+
*
92+
* @return A Result<bool> indicating whether the event matches the filter
93+
* criteria.
94+
* - True if the event matches the filter.
95+
* - False if the event does not match or is unknown.
96+
* - An error code if an error occurs during filtering.
97+
*/
98+
virtual Result<bool> filter(char* name, DebugHandle delegate_debug_index);
99+
100+
/**
101+
* Virtual destructor for the EventTracerFilterBase class.
102+
* Ensures proper cleanup of derived class objects.
103+
*/
104+
virtual ~EventTracerFilterBase();
105+
};
106+
70107
/**
71108
* Indicates the level of profiling that should be enabled. Profiling
72109
* events will be logged in increasing order of verbosity as we go down the
@@ -443,6 +480,12 @@ class EventTracer {
443480
event_tracer_profiling_level_ = profiling_level;
444481
}
445482

483+
/**
484+
* Set the filter of event tracer for delegation intermediate outputs.
485+
*/
486+
void set_delegation_intermediate_output_filter(
487+
EventTracerFilterBase* event_tracer_filter);
488+
446489
/**
447490
* Return the current level of event tracer profiling.
448491
*/

0 commit comments

Comments
 (0)