Skip to content

Commit 9ed69ae

Browse files
committed
Update on "[devtool] make ETDumpGen use datasink"
This diff enables customized debug data pipeline by making ETDumpGen leverage user-provided datasink. Details can be found in https://docs.google.com/document/d/1y_m32mKdj-OgLcLUz9TKhBW3PC3bBDYSBbeAH544EfM/edit?tab=t.0#heading=h.jlkcrurw482r Differential Revision: [D69647096](https://our.internmc.facebook.com/intern/diff/D69647096/) [ghstack-poisoned]
2 parents 9bfa193 + ca85159 commit 9ed69ae

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

devtools/etdump/buffer_data_sink.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ class BufferDataSink : public DataSinkBase {
3333
explicit BufferDataSink(::executorch::runtime::Span<uint8_t> buffer)
3434
: debug_buffer_(buffer), offset_(0) {}
3535

36-
/**
37-
* Constructs a BufferDataSink with a given ptr to data blob, and the size of data blob.
36+
/**
37+
* Constructs a BufferDataSink with a given ptr to data blob, and the size of
38+
* data blob.
3839
*
3940
* @param[in] ptr A pointer to the data blob where data will be stored.
4041
* @param[in] size The size of the data blob in bytes.
@@ -47,7 +48,6 @@ class BufferDataSink : public DataSinkBase {
4748
BufferDataSink(BufferDataSink&&) = default;
4849
BufferDataSink& operator=(BufferDataSink&&) = default;
4950

50-
5151
/**
5252
* Write data into the debug buffer and return the offset of the starting
5353
* location of the data within the buffer.

devtools/etdump/etdump_flatcc.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ using ::executorch::runtime::DebugHandle;
2929
using ::executorch::runtime::DelegateDebugIdType;
3030
using ::executorch::runtime::EValue;
3131
using ::executorch::runtime::EventTracerEntry;
32-
using ::executorch::runtime::Result;
3332
using ::executorch::runtime::LoggedEValueType;
33+
using ::executorch::runtime::Result;
3434
using ::executorch::runtime::Span;
3535
using ::executorch::runtime::Tag;
3636

@@ -379,7 +379,6 @@ void ETDumpGen::log_intermediate_output_delegate_helper(
379379
} else if constexpr (std::is_same<T, ArrayRef<Tensor>>::value) {
380380
etdump_Tensor_vec_start(builder_);
381381
for (size_t i = 0; i < output.size(); ++i) {
382-
383382
long offset = write_tensor_or_raise_error(output[i]);
384383
etdump_Tensor_vec_push(
385384
builder_, add_tensor_entry(builder_, output[i], offset));
@@ -633,14 +632,21 @@ size_t ETDumpGen::get_debug_buffer_size() const {
633632
size_t ETDumpGen::get_data_sink_size() const {
634633
ET_CHECK_MSG(data_sink_, "Must set data sink before checking its size\n");
635634
Result<size_t> ret = data_sink_->get_storage_size();
636-
ET_CHECK_MSG(ret.ok(), "Failed to get storage size with error 0x%" PRIx32, static_cast<uint32_t>(ret.error()));
635+
ET_CHECK_MSG(
636+
ret.ok(),
637+
"Failed to get storage size with error 0x%" PRIx32,
638+
static_cast<uint32_t>(ret.error()));
637639
return ret.get();
638640
}
639641

640642
long ETDumpGen::write_tensor_or_raise_error(Tensor tensor) {
641643
ET_CHECK_MSG(data_sink_, "Must set data sink before writing data\n");
642-
Result<size_t> ret = data_sink_->write(tensor.const_data_ptr(), tensor.nbytes());
643-
ET_CHECK_MSG(ret.ok(), "Failed to write tensor with error 0x%" PRIx32, static_cast<uint32_t>(ret.error()));
644+
Result<size_t> ret =
645+
data_sink_->write(tensor.const_data_ptr(), tensor.nbytes());
646+
ET_CHECK_MSG(
647+
ret.ok(),
648+
"Failed to write tensor with error 0x%" PRIx32,
649+
static_cast<uint32_t>(ret.error()));
644650
return static_cast<long>(ret.get());
645651
}
646652

devtools/etdump/etdump_flatcc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class ETDumpGen : public ::executorch::runtime::EventTracer {
173173
::executorch::runtime::DebugHandle delegate_debug_index,
174174
const T& output);
175175

176-
long write_tensor_or_raise_error(executorch::aten::Tensor tensor);
176+
long write_tensor_or_raise_error(executorch::aten::Tensor tensor);
177177

178178
struct flatcc_builder* builder_;
179179
size_t num_blocks_ = 0;

0 commit comments

Comments
 (0)