From 5dfc0cd677758f1bdbcd6e66a2cd7369cd968062 Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Fri, 1 Jul 2022 15:11:22 +0800 Subject: [PATCH] [Phi] Move all yaml to phi subdirectory (#43986) * move yaml to phi * fix undef var error --- .gitignore | 2 +- .../final_state_generator/CMakeLists.txt | 6 +- paddle/phi/api/lib/CMakeLists.txt | 65 ++++++++++--------- .../code_gen => paddle/phi/api/yaml}/api.yaml | 0 .../phi/api/yaml/api_compat.yaml | 0 .../phi/api/yaml}/api_version.yaml | 0 .../phi/api/yaml}/backward.yaml | 0 .../phi/api/yaml/generator}/api_base.py | 0 .../phi/api/yaml/generator}/api_gen.py | 6 +- .../api/yaml/generator}/backward_api_gen.py | 6 +- .../phi/api/yaml/generator}/cross_validate.py | 0 .../phi/api/yaml/generator}/filters.py | 0 .../phi/api/yaml/generator}/generate_op.py | 8 +-- .../yaml/generator}/intermediate_api_gen.py | 4 +- .../phi/api/yaml/generator}/parse_api.py | 0 .../phi/api/yaml/generator}/parse_utils.py | 0 .../phi/api/yaml/generator}/sparse_api_gen.py | 2 +- .../api/yaml/generator}/sparse_bw_api_gen.py | 7 +- .../api/yaml/generator}/strings_api_gen.py | 2 +- .../phi/api/yaml/generator}/templates/ks.c.j2 | 2 +- .../phi/api/yaml/generator}/templates/op.c.j2 | 2 +- .../generator}/templates/operator_utils.c.j2 | 0 .../phi/api/yaml/generator}/tests.py | 0 .../phi/api/yaml/generator}/type_mapping.py | 0 .../yaml/generator}/wrapped_infermeta_gen.py | 2 +- .../phi/api/yaml}/legacy_api.yaml | 0 .../phi/api/yaml}/legacy_backward.yaml | 0 .../phi/api/yaml}/sparse_api.yaml | 0 .../phi/api/yaml}/sparse_bw_api.yaml | 0 .../phi/api/yaml}/strings_api.yaml | 0 tools/infrt/generate_phi_kernel_dialect.py | 5 +- tools/infrt/get_phi_kernel_function.sh | 4 +- tools/infrt/get_phi_kernel_info.py | 4 +- 33 files changed, 63 insertions(+), 64 deletions(-) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml}/api.yaml (100%) rename python/paddle/utils/code_gen/args_compat.yaml => paddle/phi/api/yaml/api_compat.yaml (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml}/api_version.yaml (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml}/backward.yaml (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/api_base.py (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/api_gen.py (98%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/backward_api_gen.py (98%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/cross_validate.py (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/filters.py (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/generate_op.py (97%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/intermediate_api_gen.py (97%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/parse_api.py (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/parse_utils.py (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/sparse_api_gen.py (99%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/sparse_bw_api_gen.py (97%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/strings_api_gen.py (99%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/templates/ks.c.j2 (85%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/templates/op.c.j2 (93%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/templates/operator_utils.c.j2 (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/tests.py (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/type_mapping.py (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml/generator}/wrapped_infermeta_gen.py (98%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml}/legacy_api.yaml (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml}/legacy_backward.yaml (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml}/sparse_api.yaml (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml}/sparse_bw_api.yaml (100%) rename {python/paddle/utils/code_gen => paddle/phi/api/yaml}/strings_api.yaml (100%) diff --git a/.gitignore b/.gitignore index b8a2e8fbce9..25ecd77e25d 100644 --- a/.gitignore +++ b/.gitignore @@ -70,4 +70,4 @@ paddle/fluid/pybind/tmp_eager_final_state_op_function_impl.h # these files (directories) are generated before build system generation paddle/fluid/operators/generated_op.cc paddle/phi/ops/compat/generated_sig.cc -python/paddle/utils/code_gen/parsed_apis/ +paddle/phi/api/yaml/parsed_apis/ diff --git a/paddle/fluid/eager/auto_code_generator/final_state_generator/CMakeLists.txt b/paddle/fluid/eager/auto_code_generator/final_state_generator/CMakeLists.txt index 2a7e9b1cde1..8967354d244 100644 --- a/paddle/fluid/eager/auto_code_generator/final_state_generator/CMakeLists.txt +++ b/paddle/fluid/eager/auto_code_generator/final_state_generator/CMakeLists.txt @@ -1,8 +1,8 @@ set(api_yaml_path - "${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" + "${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/api.yaml,${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/legacy_api.yaml,${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/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/legacy_backward.yaml,${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/sparse_bw_api.yaml" + "${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/backward.yaml,${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/legacy_backward.yaml,${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/sparse_bw_api.yaml" ) set(tmp_forwards_cc_path "${PADDLE_SOURCE_DIR}/paddle/fluid/eager/api/generated/eager_generated/forwards/tmp_dygraph_functions.cc" @@ -30,7 +30,7 @@ set(nodes_h_path ) # StringTensor only needs forward api set(fwd_api_yaml_path - "${PADDLE_SOURCE_DIR}/python/paddle/utils/code_gen/strings_api.yaml") + "${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/strings_api.yaml") message("Final State Eager CodeGen") add_custom_target( diff --git a/paddle/phi/api/lib/CMakeLists.txt b/paddle/phi/api/lib/CMakeLists.txt index 750614561c5..2a1a6b4e78b 100644 --- a/paddle/phi/api/lib/CMakeLists.txt +++ b/paddle/phi/api/lib/CMakeLists.txt @@ -17,13 +17,13 @@ else() DEPS tensor_base dense_tensor phi_api_utils phi_enforce) endif() -set(api_gen_base ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/api_base.py) +set(api_gen_base ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/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(api_gen_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/api_gen.py) +set(api_yaml_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/api.yaml) set(legacy_api_yaml_file - ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/legacy_api.yaml) + ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/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) @@ -31,11 +31,10 @@ set(api_source_file_tmp ${api_source_file}.tmp) # backward api file 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) + ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/backward_api_gen.py) +set(bw_api_yaml_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/backward.yaml) set(legacy_bw_api_yaml_file - ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/legacy_backward.yaml) + ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/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) @@ -44,7 +43,7 @@ set(bw_api_source_file_tmp ${bw_api_source_file}.tmp) # dygraph(intermediate) api file set(im_api_gen_file - ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/intermediate_api_gen.py) + ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/intermediate_api_gen.py) set(dygraph_api_header_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/lib/dygraph_api.h) set(dygraph_api_source_file @@ -54,9 +53,9 @@ set(dygraph_api_source_file_tmp ${dygraph_api_source_file}.tmp) # sparse api file set(sparse_api_gen_file - ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/sparse_api_gen.py) + ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/sparse_api_gen.py) set(sparse_api_yaml_file - ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/sparse_api.yaml) + ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/sparse_api.yaml) set(sparse_api_header_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/include/sparse_api.h) set(sparse_api_source_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/lib/sparse_api.cc) @@ -65,9 +64,9 @@ set(sparse_api_source_file_tmp ${sparse_api_source_file}.tmp) # sparse bw api file set(sparse_bw_api_gen_file - ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/sparse_bw_api_gen.py) + ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/sparse_bw_api_gen.py) set(sparse_bw_api_yaml_file - ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/sparse_bw_api.yaml) + ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/sparse_bw_api.yaml) set(sparse_bw_api_header_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/backward/sparse_bw_api.h) set(sparse_bw_api_source_file @@ -77,9 +76,9 @@ set(sparse_bw_api_source_file_tmp ${sparse_bw_api_source_file}.tmp) # strings api file set(strings_api_gen_file - ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/strings_api_gen.py) + ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/strings_api_gen.py) set(strings_api_yaml_file - ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/strings_api.yaml) + ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/strings_api.yaml) set(strings_api_header_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/include/strings_api.h) set(strings_api_source_file @@ -89,7 +88,7 @@ set(strings_api_source_file_tmp ${strings_api_source_file}.tmp) # wrapped infermeta file set(wrapped_infermeta_gen_file - ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/wrapped_infermeta_gen.py) + ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/wrapped_infermeta_gen.py) set(wrapped_infermeta_header_file ${CMAKE_SOURCE_DIR}/paddle/phi/infermeta/generated.h) set(wrapped_infermeta_source_file @@ -109,7 +108,7 @@ else() endif() # parse apis -set(parsed_api_dir ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen/parsed_apis) +set(parsed_api_dir ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/parsed_apis) set(generated_op_path ${CMAKE_SOURCE_DIR}/paddle/fluid/operators/generated_op.cc) set(generated_argument_mapping_path @@ -121,18 +120,20 @@ message( - ${bw_api_yaml_file} - ${legacy_bw_api_yaml_file}") execute_process( - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml COMMAND ${CMAKE_COMMAND} -E make_directory ${parsed_api_dir} - COMMAND ${PYTHON_EXECUTABLE} parse_api.py --api_yaml_path ./api.yaml + COMMAND ${PYTHON_EXECUTABLE} generator/parse_api.py --api_yaml_path ./api.yaml --output_path ./parsed_apis/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} generator/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 ./legacy_backward.yaml - --output_path ./parsed_apis/legacy_backward_api.parsed.yaml --backward - RESULTS_VARIABLE _results) + ${PYTHON_EXECUTABLE} generator/parse_api.py --api_yaml_path ./backward.yaml + --output_path ./parsed_apis/backward_api.parsed.yaml --backward + COMMAND + ${PYTHON_EXECUTABLE} generator/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}) message(FATAL_ERROR "api yaml parsing failed, exiting.") @@ -144,9 +145,9 @@ message("validate api yaml: - ${parsed_api_dir}/api.parsed.yaml - ${parsed_api_dir}/backward_api.parsed.yaml") execute_process( - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml COMMAND - ${PYTHON_EXECUTABLE} cross_validate.py --forward_yaml_paths + ${PYTHON_EXECUTABLE} generator/cross_validate.py --forward_yaml_paths ./parsed_apis/api.parsed.yaml ./parsed_apis/legacy_api.parsed.yaml --backward_yaml_paths ./parsed_apis/backward_api.parsed.yaml ./parsed_apis/legacy_backward_api.parsed.yaml @@ -161,13 +162,13 @@ message( create or remove auto-geneated argument mappings: ${generated_argument_mapping_path}.tmp" ) execute_process( - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python/paddle/utils/code_gen + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml COMMAND - ${PYTHON_EXECUTABLE} generate_op.py --api_yaml_path + ${PYTHON_EXECUTABLE} generator/generate_op.py --api_yaml_path ./parsed_apis/api.parsed.yaml --backward_api_yaml_path ./parsed_apis/backward_api.parsed.yaml --api_version_yaml_path - api_version.yaml --api_args_compat_yaml_path args_compat.yaml - --output_op_path "${generated_op_path}.tmp" --output_arg_map_path + api_version.yaml --api_compat_yaml_path api_compat.yaml --output_op_path + "${generated_op_path}.tmp" --output_arg_map_path "${generated_argument_mapping_path}.tmp" RESULT_VARIABLE _result) if(${_result}) diff --git a/python/paddle/utils/code_gen/api.yaml b/paddle/phi/api/yaml/api.yaml similarity index 100% rename from python/paddle/utils/code_gen/api.yaml rename to paddle/phi/api/yaml/api.yaml diff --git a/python/paddle/utils/code_gen/args_compat.yaml b/paddle/phi/api/yaml/api_compat.yaml similarity index 100% rename from python/paddle/utils/code_gen/args_compat.yaml rename to paddle/phi/api/yaml/api_compat.yaml diff --git a/python/paddle/utils/code_gen/api_version.yaml b/paddle/phi/api/yaml/api_version.yaml similarity index 100% rename from python/paddle/utils/code_gen/api_version.yaml rename to paddle/phi/api/yaml/api_version.yaml diff --git a/python/paddle/utils/code_gen/backward.yaml b/paddle/phi/api/yaml/backward.yaml similarity index 100% rename from python/paddle/utils/code_gen/backward.yaml rename to paddle/phi/api/yaml/backward.yaml diff --git a/python/paddle/utils/code_gen/api_base.py b/paddle/phi/api/yaml/generator/api_base.py similarity index 100% rename from python/paddle/utils/code_gen/api_base.py rename to paddle/phi/api/yaml/generator/api_base.py diff --git a/python/paddle/utils/code_gen/api_gen.py b/paddle/phi/api/yaml/generator/api_gen.py similarity index 98% rename from python/paddle/utils/code_gen/api_gen.py rename to paddle/phi/api/yaml/generator/api_gen.py index a0775dd4c0a..0893d0d5578 100644 --- a/python/paddle/utils/code_gen/api_gen.py +++ b/paddle/phi/api/yaml/generator/api_gen.py @@ -154,7 +154,7 @@ class ForwardAPI(BaseAPI): 0] == 'dense' else 'SetSelectedRowsKernelOutput' if return_type == 'std::vector': assert self.outputs['out_size_expr'][0] is not None, \ - f"{api_name}: The out size expr : '{{expr}}' should be set when output has Tensor[]. You can refer 'split' api." + f"{self.api}: The out size expr : '{{expr}}' should be set when output has Tensor[]. You can refer 'split' api." output_create = output_create + f""" {code_indent} auto kernel_out = {set_out_func}({self.outputs['out_size_expr'][0]}, kernel_backend, &api_output);""" @@ -199,7 +199,7 @@ class ForwardAPI(BaseAPI): if out_dtype_list[i] == 'std::vector': assert self.outputs['out_size_expr'][i] is not None, \ - f"{api_name}: The out size expr : '{{expr}}' should be set when output has Tensor[]. You can refer 'split' api." + f"{self.api}: The out size expr : '{{expr}}' should be set when output has Tensor[]. You can refer 'split' api." output_create = output_create + f""" {code_indent} auto kernel_out_{i} = {set_out_func}({self.outputs['out_size_expr'][i]}, kernel_backend, {get_out_code});""" @@ -313,7 +313,7 @@ def main(): parser.add_argument('--api_yaml_path', help='path to api yaml file', nargs='+', - default='python/paddle/utils/code_gen/api.yaml') + default='paddle/phi/api/yaml/api.yaml') parser.add_argument('--api_header_path', help='output of generated api header code file', diff --git a/python/paddle/utils/code_gen/backward_api_gen.py b/paddle/phi/api/yaml/generator/backward_api_gen.py similarity index 98% rename from python/paddle/utils/code_gen/backward_api_gen.py rename to paddle/phi/api/yaml/generator/backward_api_gen.py index 2439eff9f63..67d47a8ec74 100644 --- a/python/paddle/utils/code_gen/backward_api_gen.py +++ b/paddle/phi/api/yaml/generator/backward_api_gen.py @@ -133,7 +133,7 @@ class BackwardAPI(BaseAPI): 0] == 'dense' else 'SetSelectedRowsKernelOutput' if out_dtype_list[0] == 'std::vector': assert self.outputs['out_size_expr'] is not None, \ - f"{api_name}: The out size expr : '{{expr}}' should be set when output has Tensor[]. You can refer 'split' api." + f"{self.api}: The out size expr : '{{expr}}' should be set when output has Tensor[]. You can refer 'split' api." output_create = output_create + f""" {code_indent} auto kernel_out = {set_out_func}(&{self.outputs['names'][0]});""" @@ -164,7 +164,7 @@ class BackwardAPI(BaseAPI): {code_indent} *{self.outputs['names'][i]} = {self.inplace_map[self.outputs['names'][i]]};""" assert self.outputs['out_size_expr'][i] is not None, \ - f"{api_name}: The out size expr : '{{expr}}' should be set when output has Tensor[]. You can refer 'split' api." + f"{self.api}: The out size expr : '{{expr}}' should be set when output has Tensor[]. You can refer 'split' api." output_create = output_create + f""" {code_indent} auto kernel_out_{i} = {set_out_func}(&{self.outputs['names'][i]});""" @@ -279,7 +279,7 @@ def main(): parser.add_argument('--backward_yaml_path', help='path to backward yaml file', nargs='+', - default='python/paddle/utils/code_gen/backward.yaml') + default='paddle/phi/api/yaml/backward.yaml') parser.add_argument('--backward_header_path', help='output of generated backward header code file', default='paddle/phi/api/backward/backward_api.h') diff --git a/python/paddle/utils/code_gen/cross_validate.py b/paddle/phi/api/yaml/generator/cross_validate.py similarity index 100% rename from python/paddle/utils/code_gen/cross_validate.py rename to paddle/phi/api/yaml/generator/cross_validate.py diff --git a/python/paddle/utils/code_gen/filters.py b/paddle/phi/api/yaml/generator/filters.py similarity index 100% rename from python/paddle/utils/code_gen/filters.py rename to paddle/phi/api/yaml/generator/filters.py diff --git a/python/paddle/utils/code_gen/generate_op.py b/paddle/phi/api/yaml/generator/generate_op.py similarity index 97% rename from python/paddle/utils/code_gen/generate_op.py rename to paddle/phi/api/yaml/generator/generate_op.py index 469e2648127..627051365c3 100644 --- a/python/paddle/utils/code_gen/generate_op.py +++ b/paddle/phi/api/yaml/generator/generate_op.py @@ -54,7 +54,7 @@ def restruct_io(api): return api -def main(api_yaml_path, backward_yaml_path, api_args_compat_yaml_path, +def main(api_yaml_path, backward_yaml_path, api_compat_yaml_path, api_version_yaml_path, output_op_path, output_arg_map_path): with open(api_yaml_path, "rt") as f: apis = yaml.safe_load(f) @@ -72,7 +72,7 @@ def main(api_yaml_path, backward_yaml_path, api_args_compat_yaml_path, for api_version in api_versions: forward_api_dict[api_version['api']]['version'] = api_version['version'] - with open(api_args_compat_yaml_path, "rt") as f: + with open(api_compat_yaml_path, "rt") as f: api_args_map = yaml.safe_load(f) # replace args name for OpMaker for api_args in api_args_map: @@ -219,7 +219,7 @@ if __name__ == "__main__": parser.add_argument('--backward_api_yaml_path', type=str, help="parsed backward api yaml file.") - parser.add_argument('--api_args_compat_yaml_path', + parser.add_argument('--api_compat_yaml_path', type=str, help="api args compat yaml file.") parser.add_argument('--api_version_yaml_path', @@ -235,5 +235,5 @@ if __name__ == "__main__": args = parser.parse_args() main(args.api_yaml_path, args.backward_api_yaml_path, - args.api_args_compat_yaml_path, args.api_version_yaml_path, + args.api_compat_yaml_path, args.api_version_yaml_path, args.output_op_path, args.output_arg_map_path) diff --git a/python/paddle/utils/code_gen/intermediate_api_gen.py b/paddle/phi/api/yaml/generator/intermediate_api_gen.py similarity index 97% rename from python/paddle/utils/code_gen/intermediate_api_gen.py rename to paddle/phi/api/yaml/generator/intermediate_api_gen.py index 017099a64a3..c8ba88d054a 100644 --- a/python/paddle/utils/code_gen/intermediate_api_gen.py +++ b/paddle/phi/api/yaml/generator/intermediate_api_gen.py @@ -134,11 +134,11 @@ def main(): parser.add_argument('--api_yaml_path', nargs='+', help='path to api yaml file', - default='python/paddle/utils/code_gen/api.yaml') + default='paddle/phi/api/yaml/api.yaml') parser.add_argument('--sparse_api_yaml_path', help='path to sparse api yaml file', - default='python/paddle/utils/code_gen/sparse_api.yaml') + default='paddle/phi/api/yaml/sparse_api.yaml') parser.add_argument('--dygraph_api_header_path', help='output of generated dygraph api header code file', diff --git a/python/paddle/utils/code_gen/parse_api.py b/paddle/phi/api/yaml/generator/parse_api.py similarity index 100% rename from python/paddle/utils/code_gen/parse_api.py rename to paddle/phi/api/yaml/generator/parse_api.py diff --git a/python/paddle/utils/code_gen/parse_utils.py b/paddle/phi/api/yaml/generator/parse_utils.py similarity index 100% rename from python/paddle/utils/code_gen/parse_utils.py rename to paddle/phi/api/yaml/generator/parse_utils.py diff --git a/python/paddle/utils/code_gen/sparse_api_gen.py b/paddle/phi/api/yaml/generator/sparse_api_gen.py similarity index 99% rename from python/paddle/utils/code_gen/sparse_api_gen.py rename to paddle/phi/api/yaml/generator/sparse_api_gen.py index aa087c9136b..17eb70e5c3e 100644 --- a/python/paddle/utils/code_gen/sparse_api_gen.py +++ b/paddle/phi/api/yaml/generator/sparse_api_gen.py @@ -280,7 +280,7 @@ def main(): description='Generate PaddlePaddle C++ Sparse API files') parser.add_argument('--api_yaml_path', help='path to sparse api yaml file', - default='python/paddle/utils/code_gen/sparse_api.yaml') + default='paddle/phi/api/yaml/sparse_api.yaml') parser.add_argument('--api_header_path', help='output of generated api header code file', diff --git a/python/paddle/utils/code_gen/sparse_bw_api_gen.py b/paddle/phi/api/yaml/generator/sparse_bw_api_gen.py similarity index 97% rename from python/paddle/utils/code_gen/sparse_bw_api_gen.py rename to paddle/phi/api/yaml/generator/sparse_bw_api_gen.py index 834e3d45d0b..e30c5e3c5d0 100644 --- a/python/paddle/utils/code_gen/sparse_bw_api_gen.py +++ b/paddle/phi/api/yaml/generator/sparse_bw_api_gen.py @@ -162,10 +162,9 @@ def generate_api(api_yaml_path, header_file_path, source_file_path): def main(): parser = argparse.ArgumentParser( description='Generate PaddlePaddle C++ Sparse API files') - parser.add_argument( - '--api_yaml_path', - help='path to sparse api yaml file', - default='python/paddle/utils/code_gen/sparse_bw_api.yaml') + parser.add_argument('--api_yaml_path', + help='path to sparse api yaml file', + default='paddle/phi/api/yaml/sparse_bw_api.yaml') parser.add_argument('--api_header_path', help='output of generated api header code file', diff --git a/python/paddle/utils/code_gen/strings_api_gen.py b/paddle/phi/api/yaml/generator/strings_api_gen.py similarity index 99% rename from python/paddle/utils/code_gen/strings_api_gen.py rename to paddle/phi/api/yaml/generator/strings_api_gen.py index 1f3ec587d74..bb5a7a2413d 100644 --- a/python/paddle/utils/code_gen/strings_api_gen.py +++ b/paddle/phi/api/yaml/generator/strings_api_gen.py @@ -351,7 +351,7 @@ def main(): description='Generate PaddlePaddle C++ Strings API files') parser.add_argument('--api_yaml_path', help='path to sparse api yaml file', - default='python/paddle/utils/code_gen/strings_api.yaml') + default='paddle/phi/api/yaml/strings_api.yaml') parser.add_argument('--api_header_path', help='output of generated api header code file', diff --git a/python/paddle/utils/code_gen/templates/ks.c.j2 b/paddle/phi/api/yaml/generator/templates/ks.c.j2 similarity index 85% rename from python/paddle/utils/code_gen/templates/ks.c.j2 rename to paddle/phi/api/yaml/generator/templates/ks.c.j2 index 54618f0e1e6..2855e05b3ca 100644 --- a/python/paddle/utils/code_gen/templates/ks.c.j2 +++ b/paddle/phi/api/yaml/generator/templates/ks.c.j2 @@ -1,5 +1,5 @@ {% from "operator_utils.c.j2" import name_map, register_name_map %} -// this file is generated by python/paddle/utils/code_gen/generate_op.py, do not edit. +// this file is generated by paddle/phi/api/yaml/generator/generate_op.py, do not edit. #include "paddle/phi/core/compat/op_utils.h" #include "paddle/utils/small_vector.h" diff --git a/python/paddle/utils/code_gen/templates/op.c.j2 b/paddle/phi/api/yaml/generator/templates/op.c.j2 similarity index 93% rename from python/paddle/utils/code_gen/templates/op.c.j2 rename to paddle/phi/api/yaml/generator/templates/op.c.j2 index 5c9559d1c89..7f13eb95825 100644 --- a/python/paddle/utils/code_gen/templates/op.c.j2 +++ b/paddle/phi/api/yaml/generator/templates/op.c.j2 @@ -1,5 +1,5 @@ {% from "operator_utils.c.j2" import op_maker, backward_op_maker, operator, register_op_with_components, register_op_version %} -// this file is generated by python/paddle/utils/code_gen/generate_op.py, do not edit. +// this file is generated by paddle/phi/api/yaml/generator/generate_op.py, do not edit. #include #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/python/paddle/utils/code_gen/templates/operator_utils.c.j2 b/paddle/phi/api/yaml/generator/templates/operator_utils.c.j2 similarity index 100% rename from python/paddle/utils/code_gen/templates/operator_utils.c.j2 rename to paddle/phi/api/yaml/generator/templates/operator_utils.c.j2 diff --git a/python/paddle/utils/code_gen/tests.py b/paddle/phi/api/yaml/generator/tests.py similarity index 100% rename from python/paddle/utils/code_gen/tests.py rename to paddle/phi/api/yaml/generator/tests.py diff --git a/python/paddle/utils/code_gen/type_mapping.py b/paddle/phi/api/yaml/generator/type_mapping.py similarity index 100% rename from python/paddle/utils/code_gen/type_mapping.py rename to paddle/phi/api/yaml/generator/type_mapping.py diff --git a/python/paddle/utils/code_gen/wrapped_infermeta_gen.py b/paddle/phi/api/yaml/generator/wrapped_infermeta_gen.py similarity index 98% rename from python/paddle/utils/code_gen/wrapped_infermeta_gen.py rename to paddle/phi/api/yaml/generator/wrapped_infermeta_gen.py index 56a55cfe806..99da6ce3d95 100644 --- a/python/paddle/utils/code_gen/wrapped_infermeta_gen.py +++ b/paddle/phi/api/yaml/generator/wrapped_infermeta_gen.py @@ -160,7 +160,7 @@ def main(): parser.add_argument('--api_yaml_path', help='path to api yaml file', nargs='+', - default='python/paddle/utils/code_gen/api.yaml') + default='paddle/phi/api/yaml/api.yaml') parser.add_argument( '--wrapped_infermeta_header_path', help='output of generated wrapped_infermeta header code file', diff --git a/python/paddle/utils/code_gen/legacy_api.yaml b/paddle/phi/api/yaml/legacy_api.yaml similarity index 100% rename from python/paddle/utils/code_gen/legacy_api.yaml rename to paddle/phi/api/yaml/legacy_api.yaml diff --git a/python/paddle/utils/code_gen/legacy_backward.yaml b/paddle/phi/api/yaml/legacy_backward.yaml similarity index 100% rename from python/paddle/utils/code_gen/legacy_backward.yaml rename to paddle/phi/api/yaml/legacy_backward.yaml diff --git a/python/paddle/utils/code_gen/sparse_api.yaml b/paddle/phi/api/yaml/sparse_api.yaml similarity index 100% rename from python/paddle/utils/code_gen/sparse_api.yaml rename to paddle/phi/api/yaml/sparse_api.yaml diff --git a/python/paddle/utils/code_gen/sparse_bw_api.yaml b/paddle/phi/api/yaml/sparse_bw_api.yaml similarity index 100% rename from python/paddle/utils/code_gen/sparse_bw_api.yaml rename to paddle/phi/api/yaml/sparse_bw_api.yaml diff --git a/python/paddle/utils/code_gen/strings_api.yaml b/paddle/phi/api/yaml/strings_api.yaml similarity index 100% rename from python/paddle/utils/code_gen/strings_api.yaml rename to paddle/phi/api/yaml/strings_api.yaml diff --git a/tools/infrt/generate_phi_kernel_dialect.py b/tools/infrt/generate_phi_kernel_dialect.py index c0a51393130..39b0d5484a8 100644 --- a/tools/infrt/generate_phi_kernel_dialect.py +++ b/tools/infrt/generate_phi_kernel_dialect.py @@ -72,12 +72,11 @@ def get_skipped_kernel_list(): def get_api_yaml_info(file_path): apis = [] - with open(file_path + "/python/paddle/utils/code_gen/api.yaml", 'r') as f: + with open(file_path + "/paddle/phi/api/yaml/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: + with open(file_path + "/paddle/phi/api/yaml/legacy_api.yaml", 'r') as f: legacy_api_list = yaml.load(f, Loader=yaml.FullLoader) if legacy_api_list: apis.extend(legacy_api_list) diff --git a/tools/infrt/get_phi_kernel_function.sh b/tools/infrt/get_phi_kernel_function.sh index 92076803cf6..69926e28cb5 100644 --- a/tools/infrt/get_phi_kernel_function.sh +++ b/tools/infrt/get_phi_kernel_function.sh @@ -77,8 +77,8 @@ 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 ${PADDLE_ROOT}/python/paddle/utils/code_gen/legacy_api.yaml \ +python3 ${PADDLE_ROOT}/paddle/phi/api/yaml/generator/wrapped_infermeta_gen.py \ + --api_yaml_path ${PADDLE_ROOT}/paddle/phi/api/yaml/api.yaml ${PADDLE_ROOT}/paddle/phi/api/yaml/legacy_api.yaml \ --wrapped_infermeta_header_path ${temp_path}/generate.h \ --wrapped_infermeta_source_path ${temp_path}/generate.cc diff --git a/tools/infrt/get_phi_kernel_info.py b/tools/infrt/get_phi_kernel_info.py index 6c4f40d215f..4837ca58213 100644 --- a/tools/infrt/get_phi_kernel_info.py +++ b/tools/infrt/get_phi_kernel_info.py @@ -20,8 +20,8 @@ import yaml 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" +api_yaml_file = "/paddle/phi/api/yaml/api.yaml" +legacy_api_yaml_file = "/paddle/phi/api/yaml/legacy_api.yaml" def get_skipped_kernel_list(): -- GitLab