Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add script to test phi op #1410

Merged
merged 6 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/deploy/main_control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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 ""
}

Expand Down Expand Up @@ -95,9 +97,14 @@ if [ $# -ge 7 ]; then
fi
fi
if [ "${OP_LIST_FILE}" == "" ]; then
OP_NAME="None"
if [ $# -ge 10 ]; then
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_NAME} \
--info_file ${OP_LIST_FILE}
return_status=$?
if [ ${return_status} -ne 0 ] || [ ! -f "${OP_LIST_FILE}" ]; then
Expand Down
77 changes: 77 additions & 0 deletions api/deploy/run_phi_op.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import datetime
import os
import argparse

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)
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)
5 changes: 5 additions & 0 deletions api/run_phi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
PWD=`pwd`
python ./deploy/run_phi_op.py --base_dir $PWD --log_dir logs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个logs的命名需不需要完善下

cd deploy
python summary.py ../logs --dump_to_excel True --dump_to_mysql False