Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / compiler / one-cmds / one-init
index 299255c..f2ddc78 100644 (file)
@@ -28,6 +28,7 @@ import os
 import sys
 
 import configparser
+import onelib.backends as backends
 import onelib.utils as oneutils
 
 # TODO Find better way to suppress trackback on error
@@ -85,45 +86,6 @@ class CommentableConfigParser(configparser.ConfigParser):
         self[section][f'{comment_sign} {comment}'] = None
 
 
-def _get_backends_list():
-    """
-    [one hierarchy]
-    one
-    ├── backends
-    ├── bin
-    ├── doc
-    ├── include
-    ├── lib
-    ├── optimization
-    └── test
-
-    The list where `one-init` finds its backends
-    - `bin` folder where `one-init` exists
-    - `backends` folder
-
-    NOTE If there are backends of the same name in different places,
-     the closer to the top in the list, the higher the priority.
-    """
-    dir_path = os.path.dirname(os.path.realpath(__file__))
-    backend_set = set()
-
-    # bin folder
-    files = [f for f in glob.glob(dir_path + '/*-init')]
-    # backends folder
-    files += [f for f in glob.glob(dir_path + '/../backends/**/*-init', recursive=True)]
-    # TODO find backends in `$PATH`
-
-    backends_list = []
-    for cand in files:
-        base = ntpath.basename(cand)
-        if (not base in backend_set) and os.path.isfile(cand) and os.access(
-                cand, os.X_OK):
-            backend_set.add(base)
-            backends_list.append(cand)
-
-    return backends_list
-
-
 # TODO Add support for TF graphdef and bcq
 def _get_parser(backends_list):
     init_usage = (
@@ -348,7 +310,7 @@ def _get_model_type(parser, args):
 
 def main():
     # get backend list
-    backends_list = _get_backends_list()
+    backends_list = backends.get_list('init')
 
     # parse arguments
     parser = _get_parser(backends_list)