def main(unused_args): 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 device!") if not os.path.exists(FLAGS.output_dir): os.mkdir(FLAGS.output_dir) target_abis = FLAGS.target_abis.split(',') if FLAGS.frameworks != "all": frameworks = FLAGS.frameworks.split(',') else: frameworks = list(FRAMEWORKS) if FLAGS.runtimes != "all": runtimes = FLAGS.runtimes.split(',') else: runtimes = list(RUNTIMES) if FLAGS.model_names != "all": model_names = FLAGS.model_names.split(',') else: model_names = list(BENCHMARK_MODELS) target = FLAGS.target host_bin_path, bin_name = sh_commands.bazel_target_to_bin(target) configs = get_configs() if "MACE" in frameworks: sh_commands.get_mace(configs, FLAGS.target_abis, FLAGS.output_dir, FLAGS.build_mace) if "TFLITE" in frameworks: sh_commands.get_tflite(configs, FLAGS.output_dir) all_prepare = [] all_run_avg = [] 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 target on host yet!") continue for serialno in target_devices: sh_commands.bazel_build(serialno, target, target_abi, frameworks, runtimes) 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 stdouts = sh_commands.adb_run( target_abi, serialno, configs, host_bin_path, bin_name, FLAGS.run_interval, FLAGS.num_threads, FLAGS.build_mace, FLAGS.max_time_per_lock, frameworks, model_names, runtimes, output_dir=FLAGS.output_dir) report_run_statistics(stdouts, target_abi, serialno, all_prepare, all_run_avg) write_all_statistics(all_prepare, all_run_avg, FLAGS.output_dir)
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_commands.bazel_build(serialno, target, target_abi, executors, device_types) 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 result_file = 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, push_list, benchmark_list, executors, DEVICE_PATH, FLAGS.output_dir) result_files.append(result_file) process_result(result_files)