()
| 57 | |
| 58 | |
| 59 | def main(): |
| 60 | parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) |
| 61 | parser.add_argument("--model_file", help="megengine model", required=True) |
| 62 | parser.add_argument( |
| 63 | "--load_and_run_file", help="path for load_and_run", required=True |
| 64 | ) |
| 65 | args = parser.parse_args() |
| 66 | assert os.path.isfile( |
| 67 | args.model_file |
| 68 | ), "invalid args for models_file, need a file for model" |
| 69 | assert os.path.isfile(args.load_and_run_file), "invalid args for load_and_run_file" |
| 70 | |
| 71 | # init device |
| 72 | ssh = SshConnector() |
| 73 | ssh.setup(device["login_name"], device["ip"], device["port"]) |
| 74 | # create test dir |
| 75 | workspace = "model_static_evaluation_workspace" |
| 76 | ssh.cmd(["mkdir -p {}".format(workspace)]) |
| 77 | # copy load_and_run_file |
| 78 | ssh.copy([args.load_and_run_file], workspace) |
| 79 | |
| 80 | model_file = args.model_file |
| 81 | # copy model file |
| 82 | ssh.copy([model_file], workspace) |
| 83 | m = model_file.split("\\")[-1] |
| 84 | # run single thread |
| 85 | cmd = "cd {} && ./load_and_run {} --fast-run --record-comp-seq --iter 1 --warmup-iter 1".format( |
| 86 | workspace, m |
| 87 | ) |
| 88 | try: |
| 89 | raw_log = ssh.cmd([cmd]) |
| 90 | except: |
| 91 | print("model: {} is not static model, it has dynamic operator.".format(m)) |
| 92 | raise |
| 93 | |
| 94 | print("model: {} is static model.".format(m)) |
| 95 | |
| 96 | |
| 97 | if __name__ == "__main__": |
no test coverage detected