Skip to content

Commit 8cd1b93

Browse files
authored
updte the return type of log_delegation_intermediate_output
Differential Revision: D71591385 Pull Request resolved: #9493
1 parent 6a4168f commit 8cd1b93

File tree

4 files changed

+56
-20
lines changed

4 files changed

+56
-20
lines changed

devtools/etdump/etdump_flatcc.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -307,39 +307,44 @@ void ETDumpGen::log_profiling_delegate(
307307
etdump_RunData_events_push_end(builder_);
308308
}
309309

310-
void ETDumpGen::log_intermediate_output_delegate(
310+
Result<bool> ETDumpGen::log_intermediate_output_delegate(
311311
const char* name,
312312
DebugHandle delegate_debug_index,
313313
const Tensor& output) {
314314
log_intermediate_output_delegate_helper(name, delegate_debug_index, output);
315+
return true;
315316
}
316317

317-
void ETDumpGen::log_intermediate_output_delegate(
318+
Result<bool> ETDumpGen::log_intermediate_output_delegate(
318319
const char* name,
319320
DebugHandle delegate_debug_index,
320321
const ArrayRef<Tensor> output) {
321322
log_intermediate_output_delegate_helper(name, delegate_debug_index, output);
323+
return true;
322324
}
323325

324-
void ETDumpGen::log_intermediate_output_delegate(
326+
Result<bool> ETDumpGen::log_intermediate_output_delegate(
325327
const char* name,
326328
DebugHandle delegate_debug_index,
327329
const int& output) {
328330
log_intermediate_output_delegate_helper(name, delegate_debug_index, output);
331+
return true;
329332
}
330333

331-
void ETDumpGen::log_intermediate_output_delegate(
334+
Result<bool> ETDumpGen::log_intermediate_output_delegate(
332335
const char* name,
333336
DebugHandle delegate_debug_index,
334337
const bool& output) {
335338
log_intermediate_output_delegate_helper(name, delegate_debug_index, output);
339+
return true;
336340
}
337341

338-
void ETDumpGen::log_intermediate_output_delegate(
342+
Result<bool> ETDumpGen::log_intermediate_output_delegate(
339343
const char* name,
340344
DebugHandle delegate_debug_index,
341345
const double& output) {
342346
log_intermediate_output_delegate_helper(name, delegate_debug_index, output);
347+
return true;
343348
}
344349

345350
template <typename T>

devtools/etdump/etdump_flatcc.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <executorch/devtools/etdump/data_sinks/buffer_data_sink.h>
1515
#include <executorch/devtools/etdump/data_sinks/data_sink_base.h>
1616
#include <executorch/runtime/core/event_tracer.h>
17+
#include <executorch/runtime/core/result.h>
1718
#include <executorch/runtime/core/span.h>
1819
#include <executorch/runtime/platform/platform.h>
1920

@@ -24,6 +25,8 @@ struct flatcc_builder;
2425
namespace executorch {
2526
namespace etdump {
2627

28+
using ::executorch::runtime::Result;
29+
2730
namespace internal {
2831
struct ETDumpStaticAllocator {
2932
ETDumpStaticAllocator() = default;
@@ -106,15 +109,15 @@ class ETDumpGen : public ::executorch::runtime::EventTracer {
106109
/**
107110
* Log an intermediate tensor output from a delegate.
108111
*/
109-
virtual void log_intermediate_output_delegate(
112+
virtual Result<bool> log_intermediate_output_delegate(
110113
const char* name,
111114
::executorch::runtime::DebugHandle delegate_debug_index,
112115
const executorch::aten::Tensor& output) override;
113116

114117
/**
115118
* Log an intermediate tensor array output from a delegate.
116119
*/
117-
virtual void log_intermediate_output_delegate(
120+
virtual Result<bool> log_intermediate_output_delegate(
118121
const char* name,
119122
::executorch::runtime::DebugHandle delegate_debug_index,
120123
const ::executorch::runtime::ArrayRef<executorch::aten::Tensor> output)
@@ -123,23 +126,23 @@ class ETDumpGen : public ::executorch::runtime::EventTracer {
123126
/**
124127
* Log an intermediate int output from a delegate.
125128
*/
126-
virtual void log_intermediate_output_delegate(
129+
virtual Result<bool> log_intermediate_output_delegate(
127130
const char* name,
128131
::executorch::runtime::DebugHandle delegate_debug_index,
129132
const int& output) override;
130133

131134
/**
132135
* Log an intermediate bool output from a delegate.
133136
*/
134-
virtual void log_intermediate_output_delegate(
137+
virtual Result<bool> log_intermediate_output_delegate(
135138
const char* name,
136139
::executorch::runtime::DebugHandle delegate_debug_index,
137140
const bool& output) override;
138141

139142
/**
140143
* Log an intermediate double output from a delegate.
141144
*/
142-
virtual void log_intermediate_output_delegate(
145+
virtual Result<bool> log_intermediate_output_delegate(
143146
const char* name,
144147
::executorch::runtime::DebugHandle delegate_debug_index,
145148
const double& output) override;

runtime/core/event_tracer.h

+26-5
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,12 @@ class EventTracer {
321321
* based names are used by this delegate to identify ops executed in the
322322
* backend then kUnsetDebugHandle should be passed in here.
323323
* @param[in] output The tensor type output to be logged.
324+
* @return A Result<bool> indicating the status of the logging operation.
325+
* - True if the tensor type output was successfully logged.
326+
* - False if the tensor type output was filtered out and not logged.
327+
* - An error code if an error occurs during logging.
324328
*/
325-
virtual void log_intermediate_output_delegate(
329+
virtual Result<bool> log_intermediate_output_delegate(
326330
const char* name,
327331
DebugHandle delegate_debug_index,
328332
const executorch::aten::Tensor& output) = 0;
@@ -341,8 +345,13 @@ class EventTracer {
341345
* based names are used by this delegate to identify ops executed in the
342346
* backend then kUnsetDebugHandle should be passed in here.
343347
* @param[in] output The tensor array type output to be logged.
348+
* @return A Result<bool> indicating the status of the logging operation.
349+
* - True if the tensor array type output was successfully logged.
350+
* - False if the tensor array type output was filtered out and not
351+
* logged.
352+
* - An error code if an error occurs during logging.
344353
*/
345-
virtual void log_intermediate_output_delegate(
354+
virtual Result<bool> log_intermediate_output_delegate(
346355
const char* name,
347356
DebugHandle delegate_debug_index,
348357
const ArrayRef<executorch::aten::Tensor> output) = 0;
@@ -361,8 +370,12 @@ class EventTracer {
361370
* based names are used by this delegate to identify ops executed in the
362371
* backend then kUnsetDebugHandle should be passed in here.
363372
* @param[in] output The int type output to be logged.
373+
* @return A Result<bool> indicating the status of the logging operation.
374+
* - True if the int type output was successfully logged.
375+
* - False if the int type output was filtered out and not logged.
376+
* - An error code if an error occurs during logging.
364377
*/
365-
virtual void log_intermediate_output_delegate(
378+
virtual Result<bool> log_intermediate_output_delegate(
366379
const char* name,
367380
DebugHandle delegate_debug_index,
368381
const int& output) = 0;
@@ -381,8 +394,12 @@ class EventTracer {
381394
* based names are used by this delegate to identify ops executed in the
382395
* backend then kUnsetDebugHandle should be passed in here.
383396
* @param[in] output The bool type output to be logged.
397+
* @return A Result<bool> indicating the status of the logging operation.
398+
* - True if the bool type output was successfully logged.
399+
* - False if the bool type output was filtered out and not logged.
400+
* - An error code if an error occurs during logging.
384401
*/
385-
virtual void log_intermediate_output_delegate(
402+
virtual Result<bool> log_intermediate_output_delegate(
386403
const char* name,
387404
DebugHandle delegate_debug_index,
388405
const bool& output) = 0;
@@ -401,8 +418,12 @@ class EventTracer {
401418
* based names are used by this delegate to identify ops executed in the
402419
* backend then kUnsetDebugHandle should be passed in here.
403420
* @param[in] output The double type output to be logged.
421+
* @return A Result<bool> indicating the status of the logging operation.
422+
* - True if the double type output was successfully logged.
423+
* - False if the double type output was filtered out and not logged.
424+
* - An error code if an error occurs during logging.
404425
*/
405-
virtual void log_intermediate_output_delegate(
426+
virtual Result<bool> log_intermediate_output_delegate(
406427
const char* name,
407428
DebugHandle delegate_debug_index,
408429
const double& output) = 0;

runtime/core/test/event_tracer_test.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <executorch/runtime/core/array_ref.h>
1313
#include <executorch/runtime/core/evalue.h>
1414
#include <executorch/runtime/core/event_tracer.h>
15+
#include <executorch/runtime/core/result.h>
1516
// Enable flag for test
1617
#define ET_EVENT_TRACER_ENABLED
1718
#include <executorch/runtime/core/event_tracer_hooks.h>
@@ -29,6 +30,7 @@ using executorch::runtime::EventTracerEntry;
2930
using executorch::runtime::kUnsetChainId;
3031
using executorch::runtime::kUnsetDebugHandle;
3132
using executorch::runtime::LoggedEValueType;
33+
using executorch::runtime::Result;
3234

3335
class DummyEventTracer : public EventTracer {
3436
public:
@@ -101,49 +103,54 @@ class DummyEventTracer : public EventTracer {
101103
(void)metadata_len;
102104
}
103105

104-
void log_intermediate_output_delegate(
106+
virtual Result<bool> log_intermediate_output_delegate(
105107
const char* name,
106108
DebugHandle delegate_debug_index,
107109
const Tensor& output) override {
108110
(void)name;
109111
(void)delegate_debug_index;
110112
(void)output;
113+
return true;
111114
}
112115

113-
void log_intermediate_output_delegate(
116+
virtual Result<bool> log_intermediate_output_delegate(
114117
const char* name,
115118
DebugHandle delegate_debug_index,
116119
const ArrayRef<Tensor> output) override {
117120
(void)name;
118121
(void)delegate_debug_index;
119122
(void)output;
123+
return true;
120124
}
121125

122-
void log_intermediate_output_delegate(
126+
virtual Result<bool> log_intermediate_output_delegate(
123127
const char* name,
124128
DebugHandle delegate_debug_index,
125129
const int& output) override {
126130
(void)name;
127131
(void)delegate_debug_index;
128132
(void)output;
133+
return true;
129134
}
130135

131-
virtual void log_intermediate_output_delegate(
136+
virtual Result<bool> log_intermediate_output_delegate(
132137
const char* name,
133138
DebugHandle delegate_debug_index,
134139
const bool& output) override {
135140
(void)name;
136141
(void)delegate_debug_index;
137142
(void)output;
143+
return true;
138144
}
139145

140-
virtual void log_intermediate_output_delegate(
146+
virtual Result<bool> log_intermediate_output_delegate(
141147
const char* name,
142148
DebugHandle delegate_debug_index,
143149
const double& output) override {
144150
(void)name;
145151
(void)delegate_debug_index;
146152
(void)output;
153+
return true;
147154
}
148155

149156
void log_evalue(const EValue& evalue, LoggedEValueType evalue_type) override {

0 commit comments

Comments
 (0)