@@ -245,6 +245,7 @@ void init_module_functions(py::module_&);
245
245
246
246
PYBIND11_MODULE (EXECUTORCH_PYTHON_MODULE_NAME, m) {
247
247
init_module_functions (m);
248
+ py::class_<executorch_flatbuffer::Program>(m, " Program" );
248
249
m.def (
249
250
" _get_program_from_buffer" ,
250
251
&_get_program_from_buffer,
@@ -253,75 +254,16 @@ PYBIND11_MODULE(EXECUTORCH_PYTHON_MODULE_NAME, m) {
253
254
" _get_program_operators" ,
254
255
&_get_program_operators,
255
256
py::return_value_policy::copy);
257
+
256
258
m.def (
257
259
" _get_io_metadata_for_program_operators" ,
258
260
&_get_io_metadata_for_program_operators,
259
261
py::return_value_policy::copy);
260
262
261
- py::class_<executorch_flatbuffer::Chain>(m, " Chain" )
262
- .def (
263
- " stacktraces" ,
264
- [](const executorch_flatbuffer::Chain& self) -> py::object {
265
- if (!self.stacktrace ()) {
266
- return py::none ();
267
- }
268
- auto stacktraces_size = self.stacktrace ()->size ();
269
- py::list stacktraces;
270
- for (size_t i = 0 ; i < stacktraces_size; ++i) {
271
- auto frames = self.stacktrace ()->Get (i)->items ();
272
- py::list frame_list;
273
- for (size_t fi = 0 ; fi < frames->size (); ++fi) {
274
- auto frame = frames->Get (fi);
275
- frame_list.append (py::make_tuple (
276
- std::string (
277
- frame->filename ()->c_str (), frame->filename ()->size ()),
278
- frame->lineno (),
279
- std::string (frame->name ()->c_str (), frame->name ()->size ()),
280
- std::string (
281
- frame->context ()->c_str (), frame->context ()->size ())));
282
- }
283
-
284
- stacktraces.append (frame_list);
285
- }
286
- return std::move (stacktraces);
287
- },
288
- py::return_value_policy::copy);
289
-
290
263
py::class_<IOMetaData>(m, " IOMetaData" )
291
264
.def_readwrite (" type" , &IOMetaData::type)
292
265
.def_readwrite (" dtype" , &IOMetaData::dtype)
293
266
.def_readwrite (" dim_order" , &IOMetaData::dim_order);
294
-
295
- py::class_<executorch_flatbuffer::ExecutionPlan>(m, " ExecutionPlan" )
296
- .def (
297
- " chain" ,
298
- [](const executorch_flatbuffer::ExecutionPlan& self, py::int_ index) {
299
- return self.chains ()->Get (index);
300
- },
301
- py::return_value_policy::reference)
302
- .def (
303
- " inputs_size" ,
304
- [](const executorch_flatbuffer::ExecutionPlan& self) -> int32_t {
305
- if (!self.inputs ()) {
306
- return -1 ;
307
- } else {
308
- return self.inputs ()->size ();
309
- }
310
- })
311
- .def (
312
- " operators" ,
313
- [](const executorch_flatbuffer::ExecutionPlan& self) -> py::list {
314
- return py::cast (get_operators_from_execution_plan (self));
315
- },
316
- py::return_value_policy::reference);
317
-
318
- py::class_<executorch_flatbuffer::Program>(m, " Program" )
319
- .def (
320
- " execution_plan" ,
321
- [](const executorch_flatbuffer::Program& self, py::int_ index) {
322
- return self.execution_plan ()->Get (index);
323
- },
324
- py::return_value_policy::reference);
325
267
}
326
268
327
269
} // namespace executor
0 commit comments