import sys
import configparser
+import onelib.backends as backends
import onelib.utils as oneutils
# TODO Find better way to suppress trackback on error
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 = (
def main():
# get backend list
- backends_list = _get_backends_list()
+ backends_list = backends.get_list('init')
# parse arguments
parser = _get_parser(backends_list)