def main(argv): global threadnum """create runner """ dpu = runner.Runner(argv[2]) listimage = os.listdir(calib_image_dir) threadAll = [] threadnum = int(argv[1]) i = 0 global runTotall runTotall = len(listimage) """image list to be run """ img = [] for i in range(runTotall): path = os.path.join(calib_image_dir, listimage[i]) image = cv2.imread(path) img.append(input_fn.preprocess_fn(image)) """run with batch """ time1 = time.time() for i in range(int(threadnum)): t1 = threading.Thread(target=runInceptionV1, args=(dpu, img, i * batchSize)) threadAll.append(t1) for x in threadAll: x.start() for x in threadAll: x.join() time2 = time.time() timetotal = time2 - time1 fps = float(runTotall / timetotal) print("%.2f FPS" % fps) del dpu
def main(argv): global threadnum listimage = [] list_files = os.listdir(test_image_dir) for filename in list_files: if "jpg" in filename: listimage.append(filename) #else: # print(filename) #print(listimage) threadAll = [] threadnum = int(argv[1]) i = 0 global runTotall runTotall = len(listimage) g = xir.graph.Graph.deserialize(pathlib.Path(argv[2])) subgraphs = get_subgraph(g) assert len(subgraphs) == 1 # only one DPU kernel all_dpu_runners = [] for i in range(int(threadnum)): all_dpu_runners.append(runner.Runner(subgraphs[0], "run")) """image list to be run """ img = [] for i in range(runTotall): path = os.path.join(test_image_dir, listimage[i]) img.append(input_fn.preprocess_fn(path)) cnt = 360 """run with batch """ time_start = time.time() for i in range(int(threadnum)): t1 = threading.Thread(target=runAlexNet, args=(all_dpu_runners[i], img, cnt)) threadAll.append(t1) for x in threadAll: x.start() for x in threadAll: x.join() time_end = time.time() timetotal = time_end - time_start total_frames = cnt * int(threadnum) fps = float(total_frames / timetotal) #print("FPS=%.2f, total frames = %.2f , time=%.6f seconds" %(fps,total_frames, timetotal)) print("FPS=%.2f, time=%.6f seconds" % (fps, timetotal))
def main(argv): global threadnum listimage=os.listdir(calib_image_dir) threadAll = [] threadnum = int(argv[1]) i = 0 global runTotall runTotall = len(listimage) g = xir.graph.Graph.deserialize(pathlib.Path(argv[2])) subgraphs = get_subgraph (g) assert len(subgraphs) == 1 # only one DPU kernel all_dpu_runners = []; for i in range(int(threadnum)): all_dpu_runners.append(runner.Runner(subgraphs[0], "run")); """image list to be run """ time1 = int(round(time.time() * 1000)) img = [] for i in range(runTotall): path = os.path.join(calib_image_dir,listimage[i]) img.append(input_fn.preprocess_fn(path)) time_pre = int(round(time.time() * 1000)) start = 0 for i in range(int(threadnum)): if (i==threadnum-1): end = len(img) else: end = start+(len(img)//threadnum) t1 = threading.Thread(target=runResnet50, args=(all_dpu_runners[i], img[start:end], len(img[start:end]))) threadAll.append(t1) start = end for x in threadAll: x.start() for x in threadAll: x.join() time2 = int(round(time.time() * 1000)) timetotal = time2 - time1 fps = float(runTotall * 1000 / timetotal) #print("Pre time: %d ms" %(time_pre - time1)) #print("DPU + post time: %d ms" %(time2 - time_pre)) #print("Total time : %d ms" %timetotal) #print("Total frames : %d" %len(img)) print("Performance : %.2f FPS" %fps)
def main(argv): global threadnum """create runner """ listimage=os.listdir(calib_image_dir) threadAll = [] threadnum = int(argv[1]) i = 0 global runTotall runTotall = len(listimage) g = xir.graph.Graph.deserialize(pathlib.Path(argv[2])) subgraphs = get_subgraph(g) assert len(subgraphs) == 1 #only one DPU kernel all_dpu_runners = []; for i in range(int(threadnum)): all_dpu_runners.append(runner.Runner(subgraphs[0], "run")) """image list to be run """ img = [] for i in range(runTotall): path = os.path.join(calib_image_dir,listimage[i]) image = cv2.imread(path) img.append(input_fn.preprocess_fn(image)) cnt = 1200 """run with batch """ time_start = time.time() for i in range(int(threadnum)): t1 = threading.Thread(target=runInceptionV1, args=(all_dpu_runners[i], img, cnt)) threadAll.append(t1) for x in threadAll: x.start() for x in threadAll: x.join() time_end = time.time() total = cnt * int(threadnum) timetotal = time_end - time_start fps = float(total / timetotal) print("%.2f FPS" %fps)
def main(argv): global threadnum listimage = os.listdir(calib_image_dir) threadAll = [] threadnum = int(argv[1]) i = 0 global runTotall runTotall = len(listimage) all_dpu_runners = [] for i in range(int(threadnum)): all_dpu_runners.append(runner.Runner(argv[2])[0]) """image list to be run """ img = [] for i in range(runTotall): path = os.path.join(calib_image_dir, listimage[i]) img.append(input_fn.preprocess_fn(path)) cnt = 360 """run with batch """ time1 = time.time() for i in range(int(threadnum)): t1 = threading.Thread(target=runResnet50, args=(all_dpu_runners[i], img, cnt)) threadAll.append(t1) for x in threadAll: x.start() for x in threadAll: x.join() time2 = time.time() timetotal = time2 - time1 total_frames = cnt * int(threadnum) fps = float(total_frames / timetotal) print("FPS=%.2f, total frames = %.2f , time=%.6f seconds" % (fps, total_frames, timetotal))