未验证 提交 54e1a7cc 编写于 作者: C Chen Weihang 提交者: GitHub

normalize yaml file name (#45894)

上级 3304e345
set(api_yaml_path
"${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"
"${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/ops.yaml,${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/legacy_ops.yaml,${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/sparse_ops.yaml"
)
set(backward_yaml_path
"${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"
"${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_backward.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}/paddle/phi/api/yaml/strings_api.yaml")
"${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/strings_ops.yaml")
message("Final State Eager CodeGen")
add_custom_target(
......
......@@ -570,15 +570,15 @@ class DygraphFunctionGeneratorBase(FunctionGeneratorBase):
grad_api_contents = self.grad_api_contents
assert 'api' in forward_api_contents.keys(
), "Unable to find \"api\" in api.yaml"
), "Unable to find \"api\" in ops.yaml"
assert 'args' in forward_api_contents.keys(
), "Unable to find \"args\" in api.yaml"
), "Unable to find \"args\" in ops.yaml"
assert 'output' in forward_api_contents.keys(
), "Unable to find \"output\" in api.yaml"
), "Unable to find \"output\" in ops.yaml"
if grad_api_contents is not None:
assert 'backward' in forward_api_contents.keys(
), "Unable to find \"backward\" in api.yaml"
), "Unable to find \"backward\" in ops.yaml"
assert 'args' in grad_api_contents.keys(
), "Unable to find \"args\" in backward.yaml"
assert 'output' in grad_api_contents.keys(
......@@ -2043,7 +2043,7 @@ if __name__ == "__main__":
api_yaml_path = api_yaml_paths[i]
# string api is forwrad only
if not api_yaml_path.endswith('strings_api.yaml'):
if not api_yaml_path.endswith('strings_ops.yaml'):
backward_yaml_path = backward_yaml_paths[i]
else:
backward_yaml_path = None
......
......@@ -21,9 +21,9 @@ 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}/paddle/phi/api/yaml/generator/api_gen.py)
set(api_yaml_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/api.yaml)
set(api_yaml_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/ops.yaml)
set(legacy_api_yaml_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/legacy_api.yaml)
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/legacy_ops.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)
......@@ -55,7 +55,7 @@ set(dygraph_api_source_file_tmp ${dygraph_api_source_file}.tmp)
set(sparse_api_gen_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/sparse_api_gen.py)
set(sparse_api_yaml_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/sparse_api.yaml)
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/sparse_ops.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)
......@@ -66,7 +66,7 @@ set(sparse_api_source_file_tmp ${sparse_api_source_file}.tmp)
set(sparse_bw_api_gen_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/sparse_bw_api_gen.py)
set(sparse_bw_api_yaml_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/sparse_bw_api.yaml)
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/sparse_backward.yaml)
set(sparse_bw_api_header_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/backward/sparse_bw_api.h)
set(sparse_bw_api_source_file
......@@ -78,7 +78,7 @@ set(sparse_bw_api_source_file_tmp ${sparse_bw_api_source_file}.tmp)
set(strings_api_gen_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/strings_api_gen.py)
set(strings_api_yaml_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/strings_api.yaml)
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/strings_ops.yaml)
set(strings_api_header_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/include/strings_api.h)
set(strings_api_source_file
......@@ -97,8 +97,7 @@ set(wrapped_infermeta_source_file
# op extra info file
set(ops_extra_info_gen_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/ops_extra_info_gen.py)
set(api_compat_yaml_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/api_compat.yaml)
set(op_compat_yaml_file ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/op_compat.yaml)
set(ops_extra_info_file
${CMAKE_SOURCE_DIR}/paddle/fluid/operators/ops_extra_info.cc)
......@@ -130,10 +129,10 @@ message(
execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml
COMMAND ${CMAKE_COMMAND} -E make_directory ${parsed_api_dir}
COMMAND ${PYTHON_EXECUTABLE} generator/parse_api.py --api_yaml_path ./api.yaml
COMMAND ${PYTHON_EXECUTABLE} generator/parse_api.py --api_yaml_path ./ops.yaml
--output_path ./parsed_apis/api.parsed.yaml
COMMAND ${PYTHON_EXECUTABLE} generator/parse_api.py --api_yaml_path
./legacy_api.yaml --output_path ./parsed_apis/legacy_api.parsed.yaml
./legacy_ops.yaml --output_path ./parsed_apis/legacy_api.parsed.yaml
COMMAND
${PYTHON_EXECUTABLE} generator/parse_api.py --api_yaml_path ./backward.yaml
--output_path ./parsed_apis/backward_api.parsed.yaml --backward
......@@ -175,7 +174,7 @@ execute_process(
${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_compat_yaml_path api_compat.yaml --output_op_path
op_version.yaml --op_compat_yaml_path op_compat.yaml --output_op_path
"${generated_op_path}.tmp" --output_arg_map_path
"${generated_argument_mapping_path}.tmp"
RESULT_VARIABLE _result)
......@@ -221,9 +220,8 @@ endif()
# generate ops extra info
execute_process(
COMMAND
${PYTHON_EXECUTABLE} ${ops_extra_info_gen_file} --api_compat_yaml_path
${api_compat_yaml_file} --ops_extra_info_path ${ops_extra_info_file})
COMMAND ${PYTHON_EXECUTABLE} ${ops_extra_info_gen_file} --op_compat_yaml_path
${op_compat_yaml_file} --ops_extra_info_path ${ops_extra_info_file})
message("generate ${ops_extra_info_file}")
# generate forward api
......
......@@ -40,7 +40,7 @@ inline bool NeedTransformPlace(const paddle::platform::Place& input,
const TransformFlag& transform_flag) {
// NOTE(dev): The default value of TransformFlag is True, if it is set with
// False
// somewhere such as api.yaml or backward.yaml that means we should skip data
// somewhere such as ops.yaml or backward.yaml that means we should skip data
// transform. Because "stop_transform_" has highest priority.
if (!transform_flag.need_trans_backend()) {
return false;
......
......@@ -881,7 +881,7 @@ PADDLE_API {self.get_return_type(inplace_flag=True)} {api_func_name}({self.get_d
def get_condition_code(self, kernel_name):
assert self.kernel['dispatch'][kernel_name], \
f"{self.api} api: the tensor type of inputs and outputs for kernel isn't set, see also 'kernel:func' of 'scale' in api.yaml."
f"{self.api} api: the tensor type of inputs and outputs for kernel isn't set, see also 'kernel:func' of 'scale' in ops.yaml."
input_types = self.kernel['dispatch'][kernel_name][0]
condition_list = []
for i, in_type in enumerate(input_types):
......
......@@ -319,7 +319,7 @@ def main():
parser.add_argument('--api_yaml_path',
help='path to api yaml file',
nargs='+',
default='paddle/phi/api/yaml/api.yaml')
default='paddle/phi/api/yaml/ops.yaml')
parser.add_argument('--api_header_path',
help='output of generated api header code file',
......
......@@ -175,7 +175,7 @@ def replace_compat_name(api_op_map, forward_api_dict, backward_api_dict):
]
def main(api_yaml_path, backward_yaml_path, api_compat_yaml_path,
def main(api_yaml_path, backward_yaml_path, op_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)
......@@ -193,7 +193,7 @@ def main(api_yaml_path, backward_yaml_path, api_compat_yaml_path,
for api_version in api_versions:
forward_api_dict[api_version['api']]['version'] = api_version['version']
with open(api_compat_yaml_path, "rt") as f:
with open(op_compat_yaml_path, "rt") as f:
api_op_map = yaml.safe_load(f)
for api in apis:
......@@ -244,7 +244,7 @@ if __name__ == "__main__":
parser.add_argument('--backward_api_yaml_path',
type=str,
help="parsed backward api yaml file.")
parser.add_argument('--api_compat_yaml_path',
parser.add_argument('--op_compat_yaml_path',
type=str,
help="api args compat yaml file.")
parser.add_argument('--api_version_yaml_path',
......@@ -260,5 +260,5 @@ if __name__ == "__main__":
args = parser.parse_args()
main(args.api_yaml_path, args.backward_api_yaml_path,
args.api_compat_yaml_path, args.api_version_yaml_path,
args.op_compat_yaml_path, args.api_version_yaml_path,
args.output_op_path, args.output_arg_map_path)
......@@ -135,11 +135,11 @@ def main():
parser.add_argument('--api_yaml_path',
nargs='+',
help='path to api yaml file',
default='paddle/phi/api/yaml/api.yaml')
default='paddle/phi/api/yaml/ops.yaml')
parser.add_argument('--sparse_api_yaml_path',
help='path to sparse api yaml file',
default='paddle/phi/api/yaml/sparse_api.yaml')
default='paddle/phi/api/yaml/sparse_ops.yaml')
parser.add_argument('--dygraph_api_header_path',
help='output of generated dygraph api header code file',
......
......@@ -65,9 +65,9 @@ def parse_attr(attr_str):
'name'), result.group('default_val')
def generate_extra_info(api_compat_yaml_path, ops_extra_info_path):
def generate_extra_info(op_compat_yaml_path, ops_extra_info_path):
compat_apis = []
with open(api_compat_yaml_path, 'rt') as f:
with open(op_compat_yaml_path, 'rt') as f:
compat_apis = yaml.safe_load(f)
def get_op_name(api_item):
......@@ -80,9 +80,9 @@ def generate_extra_info(api_compat_yaml_path, ops_extra_info_path):
extra_map_str_list = []
extra_checker_str_list = []
for api_compat_args in compat_apis:
if 'extra' in api_compat_args:
extra_args_map = api_compat_args['extra']
for op_compat_args in compat_apis:
if 'extra' in op_compat_args:
extra_args_map = op_compat_args['extra']
# TODO(chenweihang): add inputs and outputs
if 'attrs' in extra_args_map:
attr_map_list = []
......@@ -103,13 +103,13 @@ def generate_extra_info(api_compat_yaml_path, ops_extra_info_path):
api_extra_attr_checkers = ",\n ".join(
attr_checker_func_list)
extra_map_str_list.append(
f"{{\"{get_op_name(api_compat_args['api'])}\", {{ {api_extra_attr_map} }}}}"
f"{{\"{get_op_name(op_compat_args['api'])}\", {{ {api_extra_attr_map} }}}}"
)
extra_checker_str_list.append(
f"{{\"{get_op_name(api_compat_args['api'])}\", {{ {api_extra_attr_checkers} }}}}"
f"{{\"{get_op_name(op_compat_args['api'])}\", {{ {api_extra_attr_checkers} }}}}"
)
if 'backward' in api_compat_args:
for bw_item in api_compat_args['backward'].split(','):
if 'backward' in op_compat_args:
for bw_item in op_compat_args['backward'].split(','):
bw_op_name = get_op_name(bw_item)
extra_map_str_list.append(
f"{{\"{bw_op_name}\", {{ {api_extra_attr_map} }}}}")
......@@ -127,9 +127,9 @@ def generate_extra_info(api_compat_yaml_path, ops_extra_info_path):
def main():
parser = argparse.ArgumentParser(
description='Generate PaddlePaddle Extra Param Info for Op')
parser.add_argument('--api_compat_yaml_path',
parser.add_argument('--op_compat_yaml_path',
help='path to api compat yaml file',
default='paddle/phi/api/yaml/api_compat.yaml')
default='paddle/phi/api/yaml/op_compat.yaml')
parser.add_argument('--ops_extra_info_path',
help='output of generated extra_prama_info code file',
......@@ -137,10 +137,10 @@ def main():
options = parser.parse_args()
api_compat_yaml_path = options.api_compat_yaml_path
op_compat_yaml_path = options.op_compat_yaml_path
ops_extra_info_path = options.ops_extra_info_path
generate_extra_info(api_compat_yaml_path, ops_extra_info_path)
generate_extra_info(op_compat_yaml_path, ops_extra_info_path)
if __name__ == '__main__':
......
......@@ -160,7 +160,7 @@ class SparseAPI(ForwardAPI):
def get_condition_code(self, kernel_name):
assert self.kernel['dispatch'][kernel_name], \
f"{self.api} api: the tensor type of inputs and outputs for kernel isn't set, see also 'kernel:func' of 'conv3d' in sparse_api.yaml."
f"{self.api} api: the tensor type of inputs and outputs for kernel isn't set, see also 'kernel:func' of 'conv3d' in sparse_ops.yaml."
input_types = self.kernel['dispatch'][kernel_name][0]
sparse_type_map = {
'sparse_coo': 'DataLayout::SPARSE_COO',
......@@ -284,7 +284,7 @@ def main():
description='Generate PaddlePaddle C++ Sparse API files')
parser.add_argument('--api_yaml_path',
help='path to sparse api yaml file',
default='paddle/phi/api/yaml/sparse_api.yaml')
default='paddle/phi/api/yaml/sparse_ops.yaml')
parser.add_argument('--api_header_path',
help='output of generated api header code file',
......
......@@ -164,7 +164,7 @@ def main():
description='Generate PaddlePaddle C++ Sparse API files')
parser.add_argument('--api_yaml_path',
help='path to sparse api yaml file',
default='paddle/phi/api/yaml/sparse_bw_api.yaml')
default='paddle/phi/api/yaml/sparse_backward.yaml')
parser.add_argument('--api_header_path',
help='output of generated api header code file',
......
......@@ -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='paddle/phi/api/yaml/strings_api.yaml')
default='paddle/phi/api/yaml/strings_ops.yaml')
parser.add_argument('--api_header_path',
help='output of generated api header code file',
......
......@@ -167,7 +167,7 @@ def main():
parser.add_argument('--api_yaml_path',
help='path to api yaml file',
nargs='+',
default='paddle/phi/api/yaml/api.yaml')
default='paddle/phi/api/yaml/ops.yaml')
parser.add_argument(
'--wrapped_infermeta_header_path',
help='output of generated wrapped_infermeta header code file',
......
# The apis in this file are unstandardized that may caused by a variety of reasons,
# we are trying to fix these apis and will move standardized apis into api.yaml.
# we are trying to fix these apis and will move standardized apis into ops.yaml.
- api : abs
args : (Tensor x)
......
......@@ -3537,7 +3537,7 @@ void StridedSliceInferMeta(const MetaTensor& x,
/* Why not use SumRawInferMeta directly?
Because we need make InferMetaFunction's args follow the design of
api.yaml
ops.yaml
*/
void SumInferMeta(const MetaTensor& x,
const IntArray& axis,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册