diff --git a/tools/python/py_proto/__init__.py b/tools/python/py_proto/__init__.py index da5f48fd89e22d2dda0494b83a7cb4db378f79aa..c94fa6f360b9e6145c64d97deef10bfcf2db181d 100644 --- a/tools/python/py_proto/__init__.py +++ b/tools/python/py_proto/__init__.py @@ -24,11 +24,16 @@ cwd = os.path.dirname(__file__) # TODO: Remove bazel deps try: - device.execute("bazel build //mace/proto:mace_py") - device.execute("cp -f bazel-genfiles/mace/proto/mace_pb2.py %s" % cwd) - - device.execute("bazel build //third_party/caffe:caffe_py") - device.execute( - "cp -f bazel-genfiles/third_party/caffe/caffe_pb2.py %s" % cwd) + device.execute("bazel version") except: # noqa MaceLogger.warning("No bazel, use cmake.") +else: + try: + device.execute("bazel build //mace/proto:mace_py") + device.execute("cp -f bazel-genfiles/mace/proto/mace_pb2.py %s" % cwd) + + device.execute("bazel build //third_party/caffe:caffe_py") + device.execute( + "cp -f bazel-genfiles/third_party/caffe/caffe_pb2.py %s" % cwd) + except: # noqa + MaceLogger.error("Failed in proto files' building") diff --git a/tools/python/run_model.py b/tools/python/run_model.py index 52e081fae179f612cfff8e701a6f6fbfffe6ac3a..345b725be1b656445f787ff3383dd72925ec3d11 100644 --- a/tools/python/run_model.py +++ b/tools/python/run_model.py @@ -73,7 +73,7 @@ def run_models(flags, args): MaceLogger.info("Run on devices: %s" % run_devices) for device_id in run_devices: - dev = device.crete_device(flags.target_abi, device_id) + dev = device.create_device(flags.target_abi, device_id) run_models_for_device(flags, args, dev) diff --git a/tools/python/run_target.py b/tools/python/run_target.py index 370b24238b59501509695aaba89063aa0a04b252..b30dd192548ebc651031ff210ae72fbe43955c06 100644 --- a/tools/python/run_target.py +++ b/tools/python/run_target.py @@ -44,7 +44,7 @@ def run_target(target_abi, install_dir, target_obj, device_ids="all"): for device_id in run_devices: # initiate device - dev = device.crete_device(target_abi, device_id) + dev = device.create_device(target_abi, device_id) # reinstall target print("Install target from %s to %s" % (target_obj.path, install_dir)) diff --git a/tools/python/utils/device.py b/tools/python/utils/device.py index 579d70ff284e28cb9ba689cceb399504c07973e1..908a0dba69fd955400aa6fb3f2c73321e3b9b0ac 100644 --- a/tools/python/utils/device.py +++ b/tools/python/utils/device.py @@ -94,7 +94,10 @@ class HostDevice(Device): if install_dir.strip() and install_dir != os.path.dirname(target.path): execute("mkdir -p %s" % install_dir) - execute("cp %s %s" % (target.path, install_dir)) + if os.path.isdir(target.path): + execute("cp %s/* %s" % (target.path, install_dir)) + else: + execute("cp %s %s" % (target.path, install_dir)) for lib in target.libs: execute("cp %s %s" % (lib, install_dir)) @@ -285,7 +288,7 @@ def device_class(target_abi): return globals()[device_dispatch[target_abi]] -def crete_device(target_abi, device_id=None): +def create_device(target_abi, device_id=None): return device_class(target_abi)(device_id, target_abi)