|
23 | 23 | #include <gflags/gflags.h>
|
24 | 24 |
|
25 | 25 | #include <executorch/devtools/bundled_program/bundled_program.h>
|
| 26 | +#include <executorch/devtools/etdump/data_sinks/buffer_data_sink.h> |
26 | 27 | #include <executorch/devtools/etdump/etdump_flatcc.h>
|
27 | 28 | #include <executorch/extension/data_loader/buffer_data_loader.h>
|
28 | 29 | #include <executorch/runtime/executor/method.h>
|
@@ -75,6 +76,7 @@ DEFINE_int32(
|
75 | 76 | 262144, // 256 KB
|
76 | 77 | "Size of the debug buffer in bytes to allocate for intermediate outputs and program outputs logging.");
|
77 | 78 |
|
| 79 | +using executorch::etdump::BufferDataSink; |
78 | 80 | using executorch::etdump::ETDumpGen;
|
79 | 81 | using executorch::etdump::ETDumpResult;
|
80 | 82 | using executorch::extension::BufferDataLoader;
|
@@ -215,27 +217,36 @@ int main(int argc, char** argv) {
|
215 | 217 | // be used by a single thread at at time, but it can be reused.
|
216 | 218 | //
|
217 | 219 | ETDumpGen etdump_gen;
|
218 |
| - Result<Method> method = |
219 |
| - program->load_method(method_name, &memory_manager, &etdump_gen); |
220 |
| - ET_CHECK_MSG( |
221 |
| - method.ok(), |
222 |
| - "Loading of method %s failed with status 0x%" PRIx32, |
223 |
| - method_name, |
224 |
| - static_cast<int>(method.error())); |
225 |
| - ET_LOG(Info, "Method loaded."); |
226 | 220 |
|
227 | 221 | void* debug_buffer = malloc(FLAGS_debug_buffer_size);
|
| 222 | + |
| 223 | + Result<BufferDataSink> data_sink_ret = |
| 224 | + BufferDataSink::create(debug_buffer, FLAGS_debug_buffer_size); |
| 225 | + ET_CHECK_MSG( |
| 226 | + data_sink_ret.ok(), |
| 227 | + "Creating Datasink for etdump failed with status 0x%" PRIx32, |
| 228 | + static_cast<int>(data_sink_ret.error())); |
| 229 | + |
| 230 | + BufferDataSink* data_sink = &data_sink_ret.get(); |
| 231 | + etdump_gen.set_data_sink(data_sink); |
| 232 | + |
228 | 233 | if (FLAGS_dump_intermediate_outputs) {
|
229 |
| - Span<uint8_t> buffer((uint8_t*)debug_buffer, FLAGS_debug_buffer_size); |
230 |
| - etdump_gen.set_debug_buffer(buffer); |
231 | 234 | etdump_gen.set_event_tracer_debug_level(
|
232 | 235 | EventTracerDebugLogLevel::kIntermediateOutputs);
|
233 | 236 | } else if (FLAGS_dump_outputs) {
|
234 |
| - Span<uint8_t> buffer((uint8_t*)debug_buffer, FLAGS_debug_buffer_size); |
235 |
| - etdump_gen.set_debug_buffer(buffer); |
236 | 237 | etdump_gen.set_event_tracer_debug_level(
|
237 | 238 | EventTracerDebugLogLevel::kProgramOutputs);
|
238 | 239 | }
|
| 240 | + |
| 241 | + Result<Method> method = |
| 242 | + program->load_method(method_name, &memory_manager, &etdump_gen); |
| 243 | + ET_CHECK_MSG( |
| 244 | + method.ok(), |
| 245 | + "Loading of method %s failed with status 0x%" PRIx32, |
| 246 | + method_name, |
| 247 | + static_cast<int>(method.error())); |
| 248 | + ET_LOG(Info, "Method loaded."); |
| 249 | + |
239 | 250 | // Use the inputs embedded in the bundled program.
|
240 | 251 | status = executorch::bundled_program::load_bundled_input(
|
241 | 252 | *method, file_data.data(), FLAGS_testset_idx);
|
|
0 commit comments