Example #1
0
 def pull(self, src_path, dst_path='.'):
     if self.system == SystemType.android:
         sh_commands.adb_pull(src_path, dst_path, self.address)
     elif self.system == SystemType.arm_linux:
         if os.path.isdir(dst_path):
             exist_file = dst_path + '/' + src_path.split('/')[-1]
             if os.path.exists(exist_file):
                 sh.rm('-rf', exist_file)
         elif os.path.exists(dst_path):
             sh.rm('-f', dst_path)
         try:
             sh.scp('-r',
                    '%s@%s:%s' % (self.username, self.address, src_path),
                    dst_path)
         except sh.ErrorReturnCode_1 as e:
             six.print_('Error msg {}'.format(e), file=sys.stderr)
             return
Example #2
0
File: device.py Project: lbqin/mace
 def pull(self, src_path, file_name, dst_path='.'):
     if not os.path.exists(dst_path):
         sh.mkdir("-p", dst_path)
     src_file = "%s/%s" % (src_path, file_name)
     dst_file = "%s/%s" % (dst_path, file_name)
     if os.path.exists(dst_file):
         sh.rm('-f', dst_file)
     six.print_("Pull %s to %s" % (src_path, dst_path))
     if self.system == SystemType.android:
         sh_commands.adb_pull(src_file, dst_file, self.address)
     elif self.system == SystemType.arm_linux:
         try:
             sh.scp('-r',
                    '%s@%s:%s' % (self.username, self.address, src_file),
                    dst_file)
         except sh.ErrorReturnCode_1 as e:
             six.print_("Pull Failed !", file=sys.stderr)
             raise e
Example #3
0
def main(unused_args):
    aibench_check(FLAGS.benchmark_option in base_pb2.BenchmarkOption.keys(),
                  "Wrong benchmark option %s" % FLAGS.benchmark_option)
    benchmark_option = base_pb2.BenchmarkOption.Value(FLAGS.benchmark_option)
    target_socs = None
    if FLAGS.target_socs != "all":
        target_socs = set(FLAGS.target_socs.split(','))
    target_devices = sh_commands.get_target_socs_serialnos(target_socs)
    if not target_devices:
        print("No available target!")
    if FLAGS.num_targets != 0 and FLAGS.num_targets < len(target_devices):
        random.shuffle(target_devices)
        target_devices = target_devices[:FLAGS.num_targets]
    if not os.path.exists(FLAGS.output_dir):
        os.mkdir(FLAGS.output_dir)
    target_abis = FLAGS.target_abis.split(',')
    target = FLAGS.target
    host_bin_path, bin_name = sh_commands.bazel_target_to_bin(target)

    executors, device_types, push_list, benchmark_list = \
        sh_commands.prepare_all_models(
            FLAGS.executors, FLAGS.model_names, FLAGS.device_types,
            FLAGS.output_dir)

    configs = get_configs()
    input_dir = sh_commands.prepare_datasets(configs, FLAGS.output_dir,
                                             FLAGS.input_dir)

    if base_pb2.TFLITE in executors:
        sh_commands.get_tflite(configs, FLAGS.output_dir)

    result_files = []
    for target_abi in target_abis:
        print("Prepare to run models on %s" % target_abi)
        if target_abi not in ABI_TYPES:
            print("Not supported abi: %s" % target_abi)
            continue
        if target_abi == "host":
            print("Unable to run on host yet!")
            continue
        for serialno in target_devices:
            sh.adb("-s", serialno, "shell", "rm -rf %s"
                   % os.path.join(DEVICE_PATH, "result.txt"))
            if target_abi not in set(
                    sh_commands.adb_supported_abis(serialno)):
                print("Skip device %s which does not support ABI %s" %
                      (serialno, target_abi))
                continue
            sh_commands.push_all_models(serialno, DEVICE_PATH, push_list)
            for executor in executors:
                avail_device_types = \
                    sh_commands.bazel_build(serialno, target, target_abi,
                                            executor, device_types)
                product_model, target_soc = sh_commands.adb_run(
                    target_abi, serialno, host_bin_path, bin_name,
                    benchmark_option, input_dir, FLAGS.run_interval,
                    FLAGS.num_threads, FLAGS.max_time_per_lock,
                    benchmark_list, executor, avail_device_types, DEVICE_PATH)
            src_path = DEVICE_PATH + "/result.txt"
            dest_path = FLAGS.output_dir + "/" + product_model + "_" + \
                target_soc + "_" + target_abi + "_" + "result.txt"
            sh_commands.adb_pull(src_path, dest_path, serialno)
            result_files.append(dest_path)

    process_result(result_files)