From cfd814247d7a9da70bfd056d60154996f54acefc Mon Sep 17 00:00:00 2001 From: Divano Date: Tue, 22 Mar 2022 11:37:32 +0800 Subject: [PATCH 1/6] add script to test phi op --- api/deploy/main_control.sh | 1 + api/deploy/run_phi_op.py | 79 ++++++++++++++++++++++++++++++++++++++ api/run_phi.sh | 5 +++ 3 files changed, 85 insertions(+) create mode 100644 api/deploy/run_phi_op.py create mode 100644 api/run_phi.sh diff --git a/api/deploy/main_control.sh b/api/deploy/main_control.sh index c78b198b7b..82a92d3b03 100755 --- a/api/deploy/main_control.sh +++ b/api/deploy/main_control.sh @@ -98,6 +98,7 @@ if [ "${OP_LIST_FILE}" == "" ]; then OP_LIST_FILE=${OUTPUT_DIR}/api_info.txt python ${DEPLOY_DIR}/collect_api_info.py \ --test_module_name ${TEST_MODULE_NAME} \ + --specified_op_list ${10} \ --info_file ${OP_LIST_FILE} return_status=$? if [ ${return_status} -ne 0 ] || [ ! -f "${OP_LIST_FILE}" ]; then diff --git a/api/deploy/run_phi_op.py b/api/deploy/run_phi_op.py new file mode 100644 index 0000000000..fdfaff1117 --- /dev/null +++ b/api/deploy/run_phi_op.py @@ -0,0 +1,79 @@ +import datetime +import os +import argparse +import time + +import yaml +import wget + + +def get_phi_op_list(): + # 指定phi配置文件 + DATA_URL = "https://raw.githubusercontent.com/PaddlePaddle/Paddle/develop/python/paddle/utils/code_gen/api.yaml" + file_name = "phi_api_list.yaml" + + try: + if os.path.exists(file_name): + os.remove(file_name) + print("目录下已经存在旧phi列表,正在删除旧phi列表") + print("开始下载新phi列表") + wget.download(DATA_URL, out=file_name) + print("下载完成") + except Exception as e: + print("下载yaml失败") + print(e) + exit(1) + + try: + with open(file_name) as f: + yml = yaml.load(f, Loader=yaml.FullLoader) + + except Exception as e: + print("yaml 载入失败") + print(e) + exit(1) + phi_op_list = [] + for i in yml: + phi_op_list.append(i["api"]) + phi_op_string = ",".join(i for i in phi_op_list) + # print(phi_op_string) + return phi_op_string + + +def main(): + pass + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + '--base_dir', + type=str, + help='input the benchmark code directory' + ) + parser.add_argument( + '--log_dir', + type=str, + help='input the log dir' + ) + parser.add_argument( + '--op_list', + type=str, + default=None, + help='Specify the operator list.') + args = parser.parse_args() + base_dir = args.base_dir + main_control = base_dir + "/deploy/main_control.sh" + module_name = base_dir + "/dynamic_tests_v2" + configs = base_dir + "/tests_v2/configs" + logdir = args.log_dir + oplist = args.op_list + if oplist is None: + oplist = get_phi_op_list() + cmd = "bash {} {} {} {} 0 gpu speed none both dynamic {}".format(main_control, + module_name, + configs, + logdir, + oplist) + print("[cmd] {}".format(cmd)) + os.system(cmd) \ No newline at end of file diff --git a/api/run_phi.sh b/api/run_phi.sh new file mode 100644 index 0000000000..466cd79f3d --- /dev/null +++ b/api/run_phi.sh @@ -0,0 +1,5 @@ +#!/bin/bash +PWD=`pwd` +python3.8 ./deploy/run_phi_op.py --base_dir $PWD --log_dir logs +cd deploy +python3.8 summary.py ../logs --dump_to_excel True --dump_to_mysql False \ No newline at end of file From 2b8cb8110efebae003429ecebbb5038577f3ec72 Mon Sep 17 00:00:00 2001 From: Divano Date: Tue, 22 Mar 2022 14:15:44 +0800 Subject: [PATCH 2/6] add script to test phi op --- api/deploy/main_control.sh | 6 +++++- api/deploy/run_phi_op.py | 2 +- api/run_phi.sh | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api/deploy/main_control.sh b/api/deploy/main_control.sh index 82a92d3b03..9bacfeaf80 100755 --- a/api/deploy/main_control.sh +++ b/api/deploy/main_control.sh @@ -95,10 +95,14 @@ if [ $# -ge 7 ]; then fi fi if [ "${OP_LIST_FILE}" == "" ]; then + op_list="None" + if [ $# -ge 10 ]; then + op_list=${10} + fi OP_LIST_FILE=${OUTPUT_DIR}/api_info.txt python ${DEPLOY_DIR}/collect_api_info.py \ --test_module_name ${TEST_MODULE_NAME} \ - --specified_op_list ${10} \ + --specified_op_list ${op_list} \ --info_file ${OP_LIST_FILE} return_status=$? if [ ${return_status} -ne 0 ] || [ ! -f "${OP_LIST_FILE}" ]; then diff --git a/api/deploy/run_phi_op.py b/api/deploy/run_phi_op.py index fdfaff1117..c3836fa523 100644 --- a/api/deploy/run_phi_op.py +++ b/api/deploy/run_phi_op.py @@ -60,7 +60,7 @@ def main(): '--op_list', type=str, default=None, - help='Specify the operator list.') + help='specify the operator list.') args = parser.parse_args() base_dir = args.base_dir main_control = base_dir + "/deploy/main_control.sh" diff --git a/api/run_phi.sh b/api/run_phi.sh index 466cd79f3d..b2311000f5 100644 --- a/api/run_phi.sh +++ b/api/run_phi.sh @@ -1,5 +1,5 @@ #!/bin/bash PWD=`pwd` -python3.8 ./deploy/run_phi_op.py --base_dir $PWD --log_dir logs +python ./deploy/run_phi_op.py --base_dir $PWD --log_dir logs cd deploy -python3.8 summary.py ../logs --dump_to_excel True --dump_to_mysql False \ No newline at end of file +python summary.py ../logs --dump_to_excel True --dump_to_mysql False \ No newline at end of file From 231636b5c8c04e3575f72576c819344729d0c85e Mon Sep 17 00:00:00 2001 From: Divano Date: Tue, 22 Mar 2022 14:17:02 +0800 Subject: [PATCH 3/6] add script to test phi op --- api/deploy/run_phi_op.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/deploy/run_phi_op.py b/api/deploy/run_phi_op.py index c3836fa523..7e0c8bac34 100644 --- a/api/deploy/run_phi_op.py +++ b/api/deploy/run_phi_op.py @@ -71,9 +71,9 @@ def main(): if oplist is None: oplist = get_phi_op_list() cmd = "bash {} {} {} {} 0 gpu speed none both dynamic {}".format(main_control, - module_name, - configs, - logdir, - oplist) + module_name, + configs, + logdir, + oplist) print("[cmd] {}".format(cmd)) os.system(cmd) \ No newline at end of file From bf69ec61cfbcc6d3123795a268030e01dbddfeec Mon Sep 17 00:00:00 2001 From: Divano Date: Tue, 22 Mar 2022 14:17:23 +0800 Subject: [PATCH 4/6] add script to test phi op --- api/deploy/run_phi_op.py | 2 +- api/run_phi.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/deploy/run_phi_op.py b/api/deploy/run_phi_op.py index 7e0c8bac34..0ab4c0270d 100644 --- a/api/deploy/run_phi_op.py +++ b/api/deploy/run_phi_op.py @@ -76,4 +76,4 @@ def main(): logdir, oplist) print("[cmd] {}".format(cmd)) - os.system(cmd) \ No newline at end of file + os.system(cmd) diff --git a/api/run_phi.sh b/api/run_phi.sh index b2311000f5..4348178709 100644 --- a/api/run_phi.sh +++ b/api/run_phi.sh @@ -2,4 +2,4 @@ PWD=`pwd` python ./deploy/run_phi_op.py --base_dir $PWD --log_dir logs cd deploy -python summary.py ../logs --dump_to_excel True --dump_to_mysql False \ No newline at end of file +python summary.py ../logs --dump_to_excel True --dump_to_mysql False From 0caf5e835d17369fc7fb2b9da6ed21f1fe549f7e Mon Sep 17 00:00:00 2001 From: Divano Date: Tue, 22 Mar 2022 15:44:11 +0800 Subject: [PATCH 5/6] add script to test phi op --- api/deploy/main_control.sh | 8 +++++--- api/deploy/run_phi_op.py | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/deploy/main_control.sh b/api/deploy/main_control.sh index 9bacfeaf80..c414583915 100755 --- a/api/deploy/main_control.sh +++ b/api/deploy/main_control.sh @@ -14,6 +14,7 @@ function print_usage() { echo " op_list_file (optional) - the path which specified op list to test" echo " framework (optional) - paddle, tensorflow, pytorch, both" echo " testing_mode (optional) - the testing_mode of paddle. dynamic(default)|static." + echo " op_name (optional) - specified op name or list string. such as conv2d | conv1d,conv2d,conv3d." } function print_arguments() { @@ -29,6 +30,7 @@ function print_arguments() { echo "op_list_file : ${OP_LIST_FILE}" echo "framework : ${FRAMEWORK_SET[@]}" echo "testing_mode : ${TESTING_MODE}" + echo "op_name : ${OP_NAME}" echo "" } @@ -95,14 +97,14 @@ if [ $# -ge 7 ]; then fi fi if [ "${OP_LIST_FILE}" == "" ]; then - op_list="None" + OP_NAME="None" if [ $# -ge 10 ]; then - op_list=${10} + OP_NAME=${10} fi OP_LIST_FILE=${OUTPUT_DIR}/api_info.txt python ${DEPLOY_DIR}/collect_api_info.py \ --test_module_name ${TEST_MODULE_NAME} \ - --specified_op_list ${op_list} \ + --specified_op_list ${OP_NAME} \ --info_file ${OP_LIST_FILE} return_status=$? if [ ${return_status} -ne 0 ] || [ ! -f "${OP_LIST_FILE}" ]; then diff --git a/api/deploy/run_phi_op.py b/api/deploy/run_phi_op.py index 0ab4c0270d..51569cb7ee 100644 --- a/api/deploy/run_phi_op.py +++ b/api/deploy/run_phi_op.py @@ -1,7 +1,6 @@ import datetime import os import argparse -import time import yaml import wget @@ -36,7 +35,6 @@ def get_phi_op_list(): for i in yml: phi_op_list.append(i["api"]) phi_op_string = ",".join(i for i in phi_op_list) - # print(phi_op_string) return phi_op_string From 02826c00b15573125b045922aeda552db0c87907 Mon Sep 17 00:00:00 2001 From: Divano Date: Wed, 23 Mar 2022 19:54:31 +0800 Subject: [PATCH 6/6] add script to test phi op test=document_fix --- api/run_phi.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/api/run_phi.sh b/api/run_phi.sh index 4348178709..6775640b30 100644 --- a/api/run_phi.sh +++ b/api/run_phi.sh @@ -1,5 +1,6 @@ #!/bin/bash PWD=`pwd` python ./deploy/run_phi_op.py --base_dir $PWD --log_dir logs + cd deploy python summary.py ../logs --dump_to_excel True --dump_to_mysql False