未验证 提交 fcd32950 编写于 作者: Z zyfncg 提交者: GitHub

Rename yaml (#43470)

* rename yaml file

* fix merge conflict

* fix infrt
上级 346efe96
set(api_yaml_path
"${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/api.yaml,${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/new_api.yaml,${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/sparse_api.yaml"
"${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/api.yaml,${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/legacy_api.yaml,${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/sparse_api.yaml"
)
set(backward_yaml_path
"${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/backward.yaml,${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/new_backward.yaml,${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/sparse_bw_api.yaml"
"${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/backward.yaml,${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/legacy_backward.yaml,${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/sparse_bw_api.yaml"
)
set(tmp_forwards_cc_path
"${PADDLE_SOURCE_DIR}/paddle/fluid/eager/api/generated/eager_generated/forwards/tmp_dygraph_functions.cc"
......
......@@ -22,8 +22,8 @@ set(api_gen_base ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/api_base.py)
# forward api file
set(api_gen_file ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/api_gen.py)
set(api_yaml_file ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/api.yaml)
set(new_api_yaml_file
${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/new_api.yaml)
set(legacy_api_yaml_file
${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/legacy_api.yaml)
set(api_header_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/include/api.h)
set(api_source_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/lib/api.cc)
set(api_header_file_tmp ${api_header_file}.tmp)
......@@ -34,8 +34,8 @@ set(bw_api_gen_file
${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/backward_api_gen.py)
set(bw_api_yaml_file
${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/backward.yaml)
set(new_bw_api_yaml_file
${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/new_backward.yaml)
set(legacy_bw_api_yaml_file
${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/legacy_backward.yaml)
set(bw_api_header_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/backward/backward_api.h)
set(bw_api_source_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/lib/backward_api.cc)
......@@ -111,21 +111,21 @@ set(generated_argument_mapping_path
message(
"parse api yamls:
- ${api_yaml_file}
- ${new_api_yaml_file}
- ${legacy_api_yaml_file}
- ${bw_api_yaml_file}
- ${new_bw_api_yaml_file}")
- ${legacy_bw_api_yaml_file}")
execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen
COMMAND ${CMAKE_COMMAND} -E make_directory ${parsed_api_dir}
COMMAND ${PYTHON_EXECUTABLE} parse_api.py --api_yaml_path ./api.yaml
--output_path ./parsed_apis/api.parsed.yaml
COMMAND ${PYTHON_EXECUTABLE} parse_api.py --api_yaml_path ./new_api.yaml
--output_path ./parsed_apis/new_api.parsed.yaml
COMMAND ${PYTHON_EXECUTABLE} parse_api.py --api_yaml_path ./legacy_api.yaml
--output_path ./parsed_apis/legacy_api.parsed.yaml
COMMAND ${PYTHON_EXECUTABLE} parse_api.py --api_yaml_path ./backward.yaml
--output_path ./parsed_apis/backward_api.parsed.yaml --backward
COMMAND
${PYTHON_EXECUTABLE} parse_api.py --api_yaml_path ./new_backward.yaml
--output_path ./parsed_apis/new_backward_api.parsed.yaml --backward
${PYTHON_EXECUTABLE} parse_api.py --api_yaml_path ./legacy_backward.yaml
--output_path ./parsed_apis/legacy_backward_api.parsed.yaml --backward
RESULTS_VARIABLE _results)
foreach(_result in ${_results})
if(${_result})
......@@ -141,9 +141,9 @@ execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen
COMMAND
${PYTHON_EXECUTABLE} cross_validate.py --forward_yaml_paths
./parsed_apis/api.parsed.yaml ./parsed_apis/new_api.parsed.yaml
./parsed_apis/api.parsed.yaml ./parsed_apis/legacy_api.parsed.yaml
--backward_yaml_paths ./parsed_apis/backward_api.parsed.yaml
./parsed_apis/new_backward_api.parsed.yaml
./parsed_apis/legacy_backward_api.parsed.yaml
RESULT_VARIABLE _result)
if(${_result})
message(FATAL_ERROR "api validation failed, exiting.")
......@@ -158,8 +158,8 @@ execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen
COMMAND
${PYTHON_EXECUTABLE} generate_op.py --api_yaml_path
./parsed_apis/new_api.parsed.yaml --backward_api_yaml_path
./parsed_apis/new_backward_api.parsed.yaml --output_op_path
./parsed_apis/api.parsed.yaml --backward_api_yaml_path
./parsed_apis/backward_api.parsed.yaml --output_op_path
"${generated_op_path}.tmp" --output_arg_map_path
"${generated_argument_mapping_path}.tmp"
RESULT_VARIABLE _result)
......@@ -209,7 +209,7 @@ add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} -m pip install pyyaml
COMMAND
${PYTHON_EXECUTABLE} ${api_gen_file} --api_yaml_path ${api_yaml_file}
${new_api_yaml_file} --api_header_path ${api_header_file_tmp}
${legacy_api_yaml_file} --api_header_path ${api_header_file_tmp}
--api_header_path ${api_header_file_tmp} --api_source_path
${api_source_file_tmp}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${api_header_file_tmp}
......@@ -226,7 +226,7 @@ add_custom_command(
${bw_api_source_file_tmp}
COMMAND
${PYTHON_EXECUTABLE} ${bw_api_gen_file} --backward_yaml_path
${bw_api_yaml_file} ${new_bw_api_yaml_file} --backward_header_path
${bw_api_yaml_file} ${legacy_bw_api_yaml_file} --backward_header_path
${bw_api_header_file_tmp} --backward_source_path ${bw_api_source_file_tmp}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${bw_api_header_file_tmp}
${bw_api_header_file}
......@@ -293,7 +293,7 @@ add_custom_command(
OUTPUT ${dygraph_api_header_file} ${dygraph_api_source_file}
COMMAND
${PYTHON_EXECUTABLE} ${im_api_gen_file} --api_yaml_path ${api_yaml_file}
${new_api_yaml_file} --sparse_api_yaml_path ${sparse_api_yaml_file}
${legacy_api_yaml_file} --sparse_api_yaml_path ${sparse_api_yaml_file}
--dygraph_api_header_path ${dygraph_api_header_file_tmp}
--dygraph_api_source_path ${dygraph_api_source_file_tmp}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${dygraph_api_header_file_tmp}
......@@ -309,7 +309,7 @@ add_custom_command(
OUTPUT ${wrapped_infermeta_header_file} ${wrapped_infermeta_source_file}
COMMAND
${PYTHON_EXECUTABLE} ${wrapped_infermeta_gen_file} --api_yaml_path
${api_yaml_file} ${new_api_yaml_file} --wrapped_infermeta_header_path
${api_yaml_file} ${legacy_api_yaml_file} --wrapped_infermeta_header_path
${wrapped_infermeta_header_file} --wrapped_infermeta_source_path
${wrapped_infermeta_source_file}
DEPENDS ${api_yaml_file} ${wrapped_infermeta_gen_file} ${api_gen_base}
......
......@@ -43,7 +43,7 @@ if __name__ == "__main__":
parser.add_argument('--backward_yaml_paths',
type=str,
nargs='+',
default=str(current_dir / "backward.yaml.yaml"),
default=str(current_dir / "backward_api.parsed.yaml"),
help="backward api yaml file.")
args = parser.parse_args()
......
此差异已折叠。
此差异已折叠。
......@@ -71,9 +71,17 @@ def get_skipped_kernel_list():
def get_api_yaml_info(file_path):
f = open(file_path + "/python/paddle/utils/code_gen/api.yaml", "r")
cont = f.read()
return yaml.load(cont, Loader=yaml.FullLoader)
apis = []
with open(file_path + "/python/paddle/utils/code_gen/api.yaml", 'r') as f:
api_list = yaml.load(f, Loader=yaml.FullLoader)
if api_list:
apis.extend(api_list)
with open(file_path + "/python/paddle/utils/code_gen/legacy_api.yaml",
'r') as f:
legacy_api_list = yaml.load(f, Loader=yaml.FullLoader)
if legacy_api_list:
apis.extend(legacy_api_list)
return apis
def generate_kernel_name(op_name, place_str):
......
......@@ -78,7 +78,7 @@ done
#step 2:get simple general inferMeta function wrap info
temp_path=`mktemp -d`
python3 ${PADDLE_ROOT}/python/paddle/utils/code_gen/wrapped_infermeta_gen.py \
--api_yaml_path ${PADDLE_ROOT}/python/paddle/utils/code_gen/api.yaml \
--api_yaml_path ${PADDLE_ROOT}/python/paddle/utils/code_gen/api.yaml ${PADDLE_ROOT}/python/paddle/utils/code_gen/legacy_api.yaml \
--wrapped_infermeta_header_path ${temp_path}/generate.h \
--wrapped_infermeta_source_path ${temp_path}/generate.cc
......
......@@ -21,13 +21,21 @@ from typing import List, Dict, Any
skipped_phi_api_list_file = "/tools/infrt/skipped_phi_api.json"
api_yaml_file = "/python/paddle/utils/code_gen/api.yaml"
legacy_api_yaml_file = "/python/paddle/utils/code_gen/legacy_api.yaml"
def get_skipped_kernel_list():
skiped_kernel_list = []
with open(skipped_phi_api_list_file, 'r') as f:
skiped_api_list = json.load(f)
infer_meta_data = get_api_yaml_info(api_yaml_file)
infer_meta_data = []
api_meta_data = get_api_yaml_info(api_yaml_file)
legacy_api_meta_data = get_api_yaml_info(legacy_api_yaml_file)
if api_meta_data:
infer_meta_data.extend(api_meta_data)
if legacy_api_meta_data:
infer_meta_data.extend(legacy_api_meta_data)
for api in infer_meta_data:
if "kernel" not in api or "infer_meta" not in api:
continue
......@@ -365,7 +373,14 @@ if __name__ == "__main__":
args = parse_args()
skipped_phi_api_list_file = args.paddle_root_path + skipped_phi_api_list_file
api_yaml_file = args.paddle_root_path + api_yaml_file
infer_meta_data = get_api_yaml_info(api_yaml_file)
legacy_api_yaml_file = args.paddle_root_path + legacy_api_yaml_file
infer_meta_data = []
api_meta_data = get_api_yaml_info(api_yaml_file)
legacy_api_meta_data = get_api_yaml_info(legacy_api_yaml_file)
if api_meta_data:
infer_meta_data.extend(api_meta_data)
if legacy_api_meta_data:
infer_meta_data.extend(legacy_api_meta_data)
kernel_data = get_kernel_info(args.kernel_info_file)
info_meta_wrap_data = get_infermeta_info(args.infermeta_wrap_file)
attr_data = get_attr_info(args.attr_info_file)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册