@@ -94,10 +94,10 @@ using ::executorch::ET_RUNTIME_NAMESPACE::get_registered_kernels;
9494using ::executorch::ET_RUNTIME_NAMESPACE::Kernel;
9595using ::executorch::ET_RUNTIME_NAMESPACE::Method;
9696using ::executorch::ET_RUNTIME_NAMESPACE::Program;
97- using ::executorch::extension::ET_BUNDLED_MODULE_NAMESPACE::BundledModule;
9897using ::executorch::extension::BufferDataLoader;
9998using ::executorch::extension::MallocMemoryAllocator;
10099using ::executorch::extension::MmapDataLoader;
100+ using ::executorch::extension::ET_BUNDLED_MODULE_NAMESPACE::BundledModule;
101101using ::executorch::runtime::ArrayRef;
102102using ::executorch::runtime::DataLoader;
103103using ::executorch::runtime::Error;
@@ -443,43 +443,43 @@ inline std::unique_ptr<Module> load_module_from_file(
443443}
444444
445445inline py::list get_outputs_as_py_list (
446- const std::vector<EValue>& outputs,
447- bool clone_outputs = true ) {
448- const auto outputs_size = outputs.size ();
449- py::list list (outputs_size);
450- for (size_t i = 0 ; i < outputs_size; ++i) {
451- auto & v = outputs[i];
452- if (Tag::None == v.tag ) {
453- list[i] = py::none ();
454- } else if (Tag::Int == v.tag ) {
455- list[i] = py::cast (v.toInt ());
456- } else if (Tag::Double == v.tag ) {
457- list[i] = py::cast (v.toDouble ());
458- } else if (Tag::Bool == v.tag ) {
459- list[i] = py::cast (v.toBool ());
460- } else if (Tag::String == v.tag ) {
461- list[i] = py::cast (std::string (v.toString ().data ()));
462- } else if (Tag::Tensor == v.tag ) {
446+ const std::vector<EValue>& outputs,
447+ bool clone_outputs = true ) {
448+ const auto outputs_size = outputs.size ();
449+ py::list list (outputs_size);
450+ for (size_t i = 0 ; i < outputs_size; ++i) {
451+ auto & v = outputs[i];
452+ if (Tag::None == v.tag ) {
453+ list[i] = py::none ();
454+ } else if (Tag::Int == v.tag ) {
455+ list[i] = py::cast (v.toInt ());
456+ } else if (Tag::Double == v.tag ) {
457+ list[i] = py::cast (v.toDouble ());
458+ } else if (Tag::Bool == v.tag ) {
459+ list[i] = py::cast (v.toBool ());
460+ } else if (Tag::String == v.tag ) {
461+ list[i] = py::cast (std::string (v.toString ().data ()));
462+ } else if (Tag::Tensor == v.tag ) {
463463#ifdef USE_ATEN_LIB
464- // Clone so the outputs in python do not share a lifetime with the
465- // module object
466- if (clone_outputs) {
467- list[i] = py::cast (v.toTensor ().clone ());
468- } else {
469- list[i] = py::cast (v.toTensor ());
470- }
464+ // Clone so the outputs in python do not share a lifetime with the
465+ // module object
466+ if (clone_outputs) {
467+ list[i] = py::cast (v.toTensor ().clone ());
468+ } else {
469+ list[i] = py::cast (v.toTensor ());
470+ }
471471#else
472- if (clone_outputs) {
473- list[i] = py::cast (alias_attensor_to_etensor (v.toTensor ()).clone ());
472+ if (clone_outputs) {
473+ list[i] = py::cast (alias_attensor_to_etensor (v.toTensor ()).clone ());
474+ } else {
475+ list[i] = py::cast (alias_attensor_to_etensor (v.toTensor ()));
476+ }
477+ #endif
474478 } else {
475- list[i] = py::cast ( alias_attensor_to_etensor (v. toTensor ()) );
479+ ET_ASSERT_UNREACHABLE_MSG ( " Invalid model output type " );
476480 }
477- #endif
478- } else {
479- ET_ASSERT_UNREACHABLE_MSG (" Invalid model output type" );
480481 }
481- }
482- return list;
482+ return list;
483483}
484484
485485static constexpr size_t kDEFAULT_BUNDLED_INPUT_POOL_SIZE = 16 * 1024U ;
@@ -536,7 +536,8 @@ struct PyBundledModule : public BundledModule {
536536 const auto & outputs = result.get ();
537537 py::list py_outputs = get_outputs_as_py_list (outputs);
538538
539- Error status = BundledModule::verify_method_outputs (method_name, testset_idx, rtol, atol);
539+ Error status = BundledModule::verify_method_outputs (
540+ method_name, testset_idx, rtol, atol);
540541 THROW_IF_ERROR (
541542 status,
542543 " Result verification failed with status %" PRIu32,
@@ -860,7 +861,7 @@ struct PyModule final {
860861 }
861862
862863 py::list forward_single_input (
863- const torch::Tensor& inputTensor,
864+ const torch::Tensor& inputTensor,
864865 bool clone_outputs = true ) {
865866 py::list py_list;
866867 py_list.append (py::cast (inputTensor));
@@ -1126,7 +1127,8 @@ PYBIND11_MODULE(EXECUTORCH_PYTHON_MODULE_NAME, m) {
11261127 py::arg (" clone_outputs" ) = true ,
11271128 call_guard);
11281129
1129- py::class_<PyBundledModule>(m, " BundledModule" ).def (
1130+ py::class_<PyBundledModule>(m, " BundledModule" )
1131+ .def (
11301132 " verify_result_with_bundled_expected_output" ,
11311133 &PyBundledModule::verify_result_with_bundled_expected_output,
11321134 py::arg (" method_name" ),
0 commit comments