@@ -88,10 +88,12 @@ using ::executorch::extension::BufferDataLoader;
88
88
using ::executorch::extension::MallocMemoryAllocator;
89
89
using ::executorch::extension::MmapDataLoader;
90
90
using ::executorch::runtime::ArrayRef;
91
+ using ::executorch::runtime::BackendInterface;
91
92
using ::executorch::runtime::DataLoader;
92
93
using ::executorch::runtime::Error;
93
94
using ::executorch::runtime::EValue;
94
95
using ::executorch::runtime::EventTracerDebugLogLevel;
96
+ using ::executorch::runtime::get_backend_class;
95
97
using ::executorch::runtime::get_backend_name;
96
98
using ::executorch::runtime::get_num_registered_backends;
97
99
using ::executorch::runtime::get_registered_kernels;
@@ -990,6 +992,14 @@ py::list get_registered_backend_names() {
990
992
return res;
991
993
}
992
994
995
+ py::bool_ is_available (const std::string& backend_name) {
996
+ BackendInterface* backend = get_backend_class (backend_name.c_str ());
997
+ if (backend == nullptr ) {
998
+ return false ;
999
+ }
1000
+ return backend->is_available ();
1001
+ }
1002
+
993
1003
} // namespace
994
1004
995
1005
PYBIND11_MODULE (EXECUTORCH_PYTHON_MODULE_NAME, m) {
@@ -1048,6 +1058,7 @@ PYBIND11_MODULE(EXECUTORCH_PYTHON_MODULE_NAME, m) {
1048
1058
&get_registered_backend_names,
1049
1059
call_guard);
1050
1060
m.def (" _get_operator_names" , &get_operator_names);
1061
+ m.def (" _is_available" , &is_available, py::arg (" backend_name" ), call_guard);
1051
1062
m.def (" _create_profile_block" , &create_profile_block, call_guard);
1052
1063
m.def (
1053
1064
" _reset_profile_results" ,
0 commit comments