@@ -245,83 +245,28 @@ void init_module_functions(py::module_&);
245
245
246
246
PYBIND11_MODULE (EXECUTORCH_PYTHON_MODULE_NAME, m) {
247
247
init_module_functions (m);
248
+
249
+ py::class_<executorch_flatbuffer::Program>(m, " Program" );
250
+
248
251
m.def (
249
252
" _get_program_from_buffer" ,
250
253
&_get_program_from_buffer,
251
254
py::return_value_policy::reference);
255
+
252
256
m.def (
253
257
" _get_program_operators" ,
254
258
&_get_program_operators,
255
259
py::return_value_policy::copy);
260
+
256
261
m.def (
257
262
" _get_io_metadata_for_program_operators" ,
258
263
&_get_io_metadata_for_program_operators,
259
264
py::return_value_policy::copy);
260
265
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
266
py::class_<IOMetaData>(m, " IOMetaData" )
291
267
.def_readwrite (" type" , &IOMetaData::type)
292
268
.def_readwrite (" dtype" , &IOMetaData::dtype)
293
269
.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
270
}
326
271
327
272
} // namespace executor
0 commit comments