Skip to content

Commit fbb960b

Browse files
JacobSzwejbkafacebook-github-bot
authored andcommitted
delete stuff from pybindings.cpp (#110)
Summary: Pull Request resolved: #110 Dont think any of this stuff Im deleting is used. It exposes flatbuffer internals which is bad so deleting. I think the remaining stuff is just utils for selective build so we should move this out of exetensions so regular users cant see it. Reviewed By: tarun292 Differential Revision: D48577067 fbshipit-source-id: 30796b9a803cb9fb3e98a79806887b8f009c9e4d
1 parent f4ed04f commit fbb960b

File tree

1 file changed

+5
-60
lines changed

1 file changed

+5
-60
lines changed

extension/pybindings/pybindings.cpp

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -245,83 +245,28 @@ void init_module_functions(py::module_&);
245245

246246
PYBIND11_MODULE(EXECUTORCH_PYTHON_MODULE_NAME, m) {
247247
init_module_functions(m);
248+
249+
py::class_<executorch_flatbuffer::Program>(m, "Program");
250+
248251
m.def(
249252
"_get_program_from_buffer",
250253
&_get_program_from_buffer,
251254
py::return_value_policy::reference);
255+
252256
m.def(
253257
"_get_program_operators",
254258
&_get_program_operators,
255259
py::return_value_policy::copy);
260+
256261
m.def(
257262
"_get_io_metadata_for_program_operators",
258263
&_get_io_metadata_for_program_operators,
259264
py::return_value_policy::copy);
260265

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-
290266
py::class_<IOMetaData>(m, "IOMetaData")
291267
.def_readwrite("type", &IOMetaData::type)
292268
.def_readwrite("dtype", &IOMetaData::dtype)
293269
.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);
325270
}
326271

327272
} // namespace executor

0 commit comments

Comments
 (0)