97
97
262144 , // 256 KB
98
98
" Size of the debug buffer in bytes to allocate for intermediate outputs and program outputs logging." );
99
99
100
- using namespace torch ::executor;
101
- using torch::executor::util::FileDataLoader;
100
+ using executorch::etdump::ETDumpGen;
101
+ using executorch::etdump::ETDumpResult;
102
+ using executorch::extension::BufferCleanup;
103
+ using executorch::extension::BufferDataLoader;
104
+ using executorch::extension::FileDataLoader;
105
+ using executorch::runtime::DataLoader;
106
+ using executorch::runtime::EValue;
107
+ using executorch::runtime::Error;
108
+ using executorch::runtime::EventTracerDebugLogLevel;
109
+ using executorch::runtime::FreeableBuffer;
110
+ using executorch::runtime::HierarchicalAllocator;
111
+ using executorch::runtime::MemoryAllocator;
112
+ using executorch::runtime::MemoryManager;
113
+ using executorch::runtime::Method ;
114
+ using executorch::runtime::MethodMeta;
115
+ using executorch::runtime::Program;
116
+ using executorch::runtime::Result;
117
+ using executorch::runtime::Span;
118
+
119
+ namespace bundled_program = executorch::bundled_program;
102
120
103
121
int main (int argc, char ** argv) {
104
122
{
@@ -113,7 +131,7 @@ int main(int argc, char** argv) {
113
131
return 1 ;
114
132
}
115
133
116
- runtime_init ();
134
+ executorch::runtime:: runtime_init ();
117
135
118
136
gflags::ParseCommandLineFlags (&argc, &argv, true );
119
137
if (argc != 1 ) {
@@ -144,20 +162,20 @@ int main(int argc, char** argv) {
144
162
// Find the offset to the embedded Program.
145
163
const void * program_data;
146
164
size_t program_data_len;
147
- Error status = torch::executor:: bundled_program::GetProgramData (
165
+ Error status = bundled_program::get_program_data (
148
166
const_cast <void *>(file_data->data ()),
149
167
file_data->size (),
150
168
&program_data,
151
169
&program_data_len);
152
170
ET_CHECK_MSG (
153
171
status == Error::Ok,
154
- " GetProgramData () failed on file '%s': 0x%x" ,
172
+ " get_program_data () failed on file '%s': 0x%x" ,
155
173
model_path,
156
174
(unsigned int )status);
157
175
158
176
// Wrap the buffer in a DataLoader.
159
177
auto buffer_data_loader =
160
- util:: BufferDataLoader (program_data, program_data_len);
178
+ BufferDataLoader (program_data, program_data_len);
161
179
162
180
// Parse the program file. This is immutable, and can also be reused between
163
181
// multiple execution invocations across multiple threads.
@@ -239,7 +257,7 @@ HierarchicalAllocator planned_memory(
239
257
// be used by a single thread at at time, but it can be reused.
240
258
//
241
259
242
- torch::executor:: ETDumpGen etdump_gen = torch::executor::ETDumpGen() ;
260
+ ETDumpGen etdump_gen;
243
261
Result<Method > method =
244
262
program->load_method (method_name, &memory_manager, &etdump_gen);
245
263
ET_CHECK_MSG (
@@ -263,11 +281,11 @@ HierarchicalAllocator planned_memory(
263
281
}
264
282
265
283
// Prepare the inputs.
266
- std::unique_ptr<util:: BufferCleanup> inputs;
284
+ std::unique_ptr<BufferCleanup> inputs;
267
285
if (FLAGS_bundled_program) {
268
286
ET_LOG (Info, " Loading bundled program..." );
269
287
// Use the inputs embedded in the bundled program.
270
- status = torch::executor:: bundled_program::LoadBundledInput (
288
+ status = bundled_program::load_bundled_input (
271
289
*method,
272
290
file_data->data (),
273
291
FLAGS_testset_idx);
@@ -278,11 +296,11 @@ HierarchicalAllocator planned_memory(
278
296
} else {
279
297
ET_LOG (Info, " Loading non-bundled program...\n " );
280
298
// Use ones-initialized inputs.
281
- auto inputs_result = torch::executor::util ::prepare_input_tensors (*method);
299
+ auto inputs_result = executorch::extension ::prepare_input_tensors (*method);
282
300
if (inputs_result.ok ()) {
283
301
// Will free the inputs when destroyed.
284
302
inputs =
285
- std::make_unique<util:: BufferCleanup>(std::move (inputs_result.get ()));
303
+ std::make_unique<BufferCleanup>(std::move (inputs_result.get ()));
286
304
}
287
305
}
288
306
ET_LOG (Info, " Inputs prepared." );
@@ -322,14 +340,14 @@ HierarchicalAllocator planned_memory(
322
340
status = method->get_outputs (outputs.data(), outputs.size());
323
341
ET_CHECK (status == Error::Ok);
324
342
// Print the first and last 100 elements of long lists of scalars.
325
- std::cout << torch::executor::util ::evalue_edge_items(100 );
343
+ std::cout << executorch::extension ::evalue_edge_items(100 );
326
344
for (int i = 0 ; i < outputs.size(); ++i) {
327
345
std::cout << " Output " << i << " : " << outputs[i] << std::endl;
328
346
}
329
347
330
348
// Dump the etdump data containing profiling/debugging data to the specified
331
349
// file.
332
- etdump_result result = etdump_gen.get_etdump_data();
350
+ ETDumpResult result = etdump_gen.get_etdump_data();
333
351
if (result.buf != nullptr && result.size > 0 ) {
334
352
FILE* f = fopen (FLAGS_etdump_path.c_str (), " w+" );
335
353
fwrite ((uint8_t *)result.buf , 1 , result.size , f);
@@ -362,7 +380,7 @@ HierarchicalAllocator planned_memory(
362
380
atol = 1e-01 ;
363
381
rtol = 1e-01 ;
364
382
}
365
- status = torch::executor:: bundled_program::VerifyResultWithBundledExpectedOutput (
383
+ status = bundled_program::verify_method_outputs (
366
384
*method,
367
385
file_data->data (),
368
386
FLAGS_testset_idx,
0 commit comments