Skip to content

updte the return type of log_delegation_intermediate_output #9493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions devtools/etdump/etdump_flatcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,39 +307,44 @@ void ETDumpGen::log_profiling_delegate(
etdump_RunData_events_push_end(builder_);
}

void ETDumpGen::log_intermediate_output_delegate(
Result<bool> ETDumpGen::log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const Tensor& output) {
log_intermediate_output_delegate_helper(name, delegate_debug_index, output);
return true;
}

void ETDumpGen::log_intermediate_output_delegate(
Result<bool> ETDumpGen::log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const ArrayRef<Tensor> output) {
log_intermediate_output_delegate_helper(name, delegate_debug_index, output);
return true;
}

void ETDumpGen::log_intermediate_output_delegate(
Result<bool> ETDumpGen::log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const int& output) {
log_intermediate_output_delegate_helper(name, delegate_debug_index, output);
return true;
}

void ETDumpGen::log_intermediate_output_delegate(
Result<bool> ETDumpGen::log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const bool& output) {
log_intermediate_output_delegate_helper(name, delegate_debug_index, output);
return true;
}

void ETDumpGen::log_intermediate_output_delegate(
Result<bool> ETDumpGen::log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const double& output) {
log_intermediate_output_delegate_helper(name, delegate_debug_index, output);
return true;
}

template <typename T>
Expand Down
13 changes: 8 additions & 5 deletions devtools/etdump/etdump_flatcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <executorch/devtools/etdump/data_sinks/buffer_data_sink.h>
#include <executorch/devtools/etdump/data_sinks/data_sink_base.h>
#include <executorch/runtime/core/event_tracer.h>
#include <executorch/runtime/core/result.h>
#include <executorch/runtime/core/span.h>
#include <executorch/runtime/platform/platform.h>

Expand All @@ -24,6 +25,8 @@ struct flatcc_builder;
namespace executorch {
namespace etdump {

using ::executorch::runtime::Result;

namespace internal {
struct ETDumpStaticAllocator {
ETDumpStaticAllocator() = default;
Expand Down Expand Up @@ -106,15 +109,15 @@ class ETDumpGen : public ::executorch::runtime::EventTracer {
/**
* Log an intermediate tensor output from a delegate.
*/
virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
::executorch::runtime::DebugHandle delegate_debug_index,
const executorch::aten::Tensor& output) override;

/**
* Log an intermediate tensor array output from a delegate.
*/
virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
::executorch::runtime::DebugHandle delegate_debug_index,
const ::executorch::runtime::ArrayRef<executorch::aten::Tensor> output)
Expand All @@ -123,23 +126,23 @@ class ETDumpGen : public ::executorch::runtime::EventTracer {
/**
* Log an intermediate int output from a delegate.
*/
virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
::executorch::runtime::DebugHandle delegate_debug_index,
const int& output) override;

/**
* Log an intermediate bool output from a delegate.
*/
virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
::executorch::runtime::DebugHandle delegate_debug_index,
const bool& output) override;

/**
* Log an intermediate double output from a delegate.
*/
virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
::executorch::runtime::DebugHandle delegate_debug_index,
const double& output) override;
Expand Down
31 changes: 26 additions & 5 deletions runtime/core/event_tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,12 @@ class EventTracer {
* based names are used by this delegate to identify ops executed in the
* backend then kUnsetDebugHandle should be passed in here.
* @param[in] output The tensor type output to be logged.
* @return A Result<bool> indicating the status of the logging operation.
* - True if the tensor type output was successfully logged.
* - False if the tensor type output was filtered out and not logged.
* - An error code if an error occurs during logging.
*/
virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const executorch::aten::Tensor& output) = 0;
Expand All @@ -341,8 +345,13 @@ class EventTracer {
* based names are used by this delegate to identify ops executed in the
* backend then kUnsetDebugHandle should be passed in here.
* @param[in] output The tensor array type output to be logged.
* @return A Result<bool> indicating the status of the logging operation.
* - True if the tensor array type output was successfully logged.
* - False if the tensor array type output was filtered out and not
* logged.
* - An error code if an error occurs during logging.
*/
virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const ArrayRef<executorch::aten::Tensor> output) = 0;
Expand All @@ -361,8 +370,12 @@ class EventTracer {
* based names are used by this delegate to identify ops executed in the
* backend then kUnsetDebugHandle should be passed in here.
* @param[in] output The int type output to be logged.
* @return A Result<bool> indicating the status of the logging operation.
* - True if the int type output was successfully logged.
* - False if the int type output was filtered out and not logged.
* - An error code if an error occurs during logging.
*/
virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const int& output) = 0;
Expand All @@ -381,8 +394,12 @@ class EventTracer {
* based names are used by this delegate to identify ops executed in the
* backend then kUnsetDebugHandle should be passed in here.
* @param[in] output The bool type output to be logged.
* @return A Result<bool> indicating the status of the logging operation.
* - True if the bool type output was successfully logged.
* - False if the bool type output was filtered out and not logged.
* - An error code if an error occurs during logging.
*/
virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const bool& output) = 0;
Expand All @@ -401,8 +418,12 @@ class EventTracer {
* based names are used by this delegate to identify ops executed in the
* backend then kUnsetDebugHandle should be passed in here.
* @param[in] output The double type output to be logged.
* @return A Result<bool> indicating the status of the logging operation.
* - True if the double type output was successfully logged.
* - False if the double type output was filtered out and not logged.
* - An error code if an error occurs during logging.
*/
virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const double& output) = 0;
Expand Down
17 changes: 12 additions & 5 deletions runtime/core/test/event_tracer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <executorch/runtime/core/array_ref.h>
#include <executorch/runtime/core/evalue.h>
#include <executorch/runtime/core/event_tracer.h>
#include <executorch/runtime/core/result.h>
// Enable flag for test
#define ET_EVENT_TRACER_ENABLED
#include <executorch/runtime/core/event_tracer_hooks.h>
Expand All @@ -29,6 +30,7 @@ using executorch::runtime::EventTracerEntry;
using executorch::runtime::kUnsetChainId;
using executorch::runtime::kUnsetDebugHandle;
using executorch::runtime::LoggedEValueType;
using executorch::runtime::Result;

class DummyEventTracer : public EventTracer {
public:
Expand Down Expand Up @@ -101,49 +103,54 @@ class DummyEventTracer : public EventTracer {
(void)metadata_len;
}

void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const Tensor& output) override {
(void)name;
(void)delegate_debug_index;
(void)output;
return true;
}

void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const ArrayRef<Tensor> output) override {
(void)name;
(void)delegate_debug_index;
(void)output;
return true;
}

void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const int& output) override {
(void)name;
(void)delegate_debug_index;
(void)output;
return true;
}

virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const bool& output) override {
(void)name;
(void)delegate_debug_index;
(void)output;
return true;
}

virtual void log_intermediate_output_delegate(
virtual Result<bool> log_intermediate_output_delegate(
const char* name,
DebugHandle delegate_debug_index,
const double& output) override {
(void)name;
(void)delegate_debug_index;
(void)output;
return true;
}

void log_evalue(const EValue& evalue, LoggedEValueType evalue_type) override {
Expand Down
Loading