From a9e4c0c7119989913196b313aa4f5746cd71733e Mon Sep 17 00:00:00 2001 From: ooooo <3164076421@qq.com> Date: Fri, 13 Oct 2023 18:38:30 +0800 Subject: [PATCH 01/29] make a try --- ci_scripts/check_api_cn.sh | 5 ++ ci_scripts/check_api_label_cn.py | 86 ++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 ci_scripts/check_api_label_cn.py diff --git a/ci_scripts/check_api_cn.sh b/ci_scripts/check_api_cn.sh index 80b9f7cdc3b..293b9856208 100644 --- a/ci_scripts/check_api_cn.sh +++ b/ci_scripts/check_api_cn.sh @@ -1,9 +1,11 @@ #!/bin/bash set -x +FLUIDDOCDIR=${FLUIDDOCDIR:=/FluidDoc} OUTPUTDIR=${OUTPUTDIR:=/docs} VERSIONSTR=${VERSIONSTR:=develop} +DOCROOT=${FLUIDDOCDIR}/docs/ SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" source ${SCRIPT_DIR}/utils.sh @@ -40,3 +42,6 @@ if [ $? -ne 0 ];then echo "ERROR: Exist COPY-FROM has not been parsed into sample code, please check COPY-FROM in the above files" exit 1 fi + +echo "Run API_LABEL Checking" +python check_api_label_cn.py ${DOCROOT} $need_check_cn_doc_files \ No newline at end of file diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py new file mode 100644 index 00000000000..1f4d7d8f11a --- /dev/null +++ b/ci_scripts/check_api_label_cn.py @@ -0,0 +1,86 @@ +import sys +import os +import re + +# check file's api_label +def check_api_label(rootdir, file): + real_file = rootdir + file + with open(real_file, 'r', encoding='utf-8') as f: + first_line = f.readline() + if first_line == en_label_creater(file): + return True + return False + + +# path -> api_label(the fist line 's style) +def en_label_creater(file): + result = re.sub("api/", "", file) + result = re.sub("_cn.rst", "", result) + result = re.sub('/', "_", result) + result = '.. _cn_' + result + ':' + return result + + +# traverse doc/api to append api_label in list +def traverse_api_label(rootdir): + list = [] + for root, dirs, files in os.walk(rootdir + 'api/'): + for file in files: + real_path = os.path.join(root, file) + path = re.sub(rootdir, "", real_path) + if test_ornot(path): + for label in get_api_label_list(real_path): + list.append(label) + return list + + +# api_labels in a file +def get_api_label_list(file_path): + list = [] + with open(file_path, 'r', encoding='utf-8') as f: + lines = f.readlines() + for line in lines: + if line.startswith(".. _cn"): + line = re.sub(".. _", "", line) + line = re.sub(":", "", line) + list.append(line.rstrip()) + return list + + +# api doc for checking +def test_ornot(file): + if ( + file.endswith("_cn.rst") + and (file not in ["Overview_cn.rst", "index_cn.rst"]) + and file.startswith("api") + ): + return True + return False + + +def pipline(rootdir, files): + for file in files: + if test_ornot(file): + if check_api_label(rootdir, file): + pass + else: + print("error:", file) + list = traverse_api_label(rootdir) + for file in files: + with open(rootdir + file, 'r', encoding='utf-8') as f: + pattern = f.read() + matches = re.findall(r":ref:`([^`]+)`", pattern) + if matches: + for match in matches: + if match.startswith('cn'): + if match not in list: + print(rootdir + file, 'ref' + match, 'error') + else: + out = re.search("<(.*?)>", match) + if out and out.group(1).startswith("cn"): + if out.group(1) not in list: + print(rootdir + file, 'ref' + match, 'error') + + +if __name__ == "__main__": + pipline(sys.argv[1], sys.argv[2:]) From 5d5bf2778e28d17706be9844db267995dac835a5 Mon Sep 17 00:00:00 2001 From: ooooo <3164076421@qq.com> Date: Sat, 14 Oct 2023 11:29:03 +0800 Subject: [PATCH 02/29] first fix --- ci_scripts/check_api_cn.sh | 4 +- ci_scripts/check_api_label_cn.py | 133 +++++++++++++++++++++---------- 2 files changed, 93 insertions(+), 44 deletions(-) diff --git a/ci_scripts/check_api_cn.sh b/ci_scripts/check_api_cn.sh index 293b9856208..1a87d1923a3 100644 --- a/ci_scripts/check_api_cn.sh +++ b/ci_scripts/check_api_cn.sh @@ -6,6 +6,8 @@ OUTPUTDIR=${OUTPUTDIR:=/docs} VERSIONSTR=${VERSIONSTR:=develop} DOCROOT=${FLUIDDOCDIR}/docs/ +APIROOT=${DOCROOT}/api/ + SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" source ${SCRIPT_DIR}/utils.sh @@ -44,4 +46,4 @@ if [ $? -ne 0 ];then fi echo "Run API_LABEL Checking" -python check_api_label_cn.py ${DOCROOT} $need_check_cn_doc_files \ No newline at end of file +python check_api_label_cn.py ${DOCROOT} ${APIROOT} $need_check_cn_doc_files \ No newline at end of file diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index 1f4d7d8f11a..3ebf59cecb3 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -1,86 +1,133 @@ import sys import os import re +import logging +import argparse +from pathlib import Path + +logger = logging.getLogger() +if logger.handlers: + # we assume the first handler is the one we want to configure + console = logger.handlers[0] +else: + console = logging.StreamHandler() + logger.addHandler(console) +console.setFormatter( + logging.Formatter( + "%(asctime)s - %(funcName)s:%(lineno)d - %(levelname)s - %(message)s" + ) +) +logger.setLevel(logging.INFO) # check file's api_label def check_api_label(rootdir, file): - real_file = rootdir + file + real_file = Path(rootdir) / file with open(real_file, 'r', encoding='utf-8') as f: first_line = f.readline() - if first_line == en_label_creater(file): + if first_line == generate_en_label_by_path(file): return True return False -# path -> api_label(the fist line 's style) -def en_label_creater(file): - result = re.sub("api/", "", file) - result = re.sub("_cn.rst", "", result) - result = re.sub('/', "_", result) - result = '.. _cn_' + result + ':' +# path -> api_label (the first line's style) +def generate_en_label_by_path(file): + result = file.removeprefix(API) + result = result.removesuffix('_cn.rst') + result = result.replace('/', '_') + result = f'.. _cn_{result}:' return result # traverse doc/api to append api_label in list -def traverse_api_label(rootdir): - list = [] - for root, dirs, files in os.walk(rootdir + 'api/'): +def find_all_api_labels_in_dir(rootdir): + all_api_labels = [] + for root, dirs, files in os.walk(rootdir + API): for file in files: real_path = os.path.join(root, file) - path = re.sub(rootdir, "", real_path) - if test_ornot(path): - for label in get_api_label_list(real_path): - list.append(label) - return list + path = real_path.removeprefix(rootdir) + if should_test(path): + for label in find_api_labels_in_one_file(real_path): + all_api_labels.append(label) + return all_api_labels # api_labels in a file -def get_api_label_list(file_path): - list = [] +def find_api_labels_in_one_file(file_path): + api_labels_in_one_file = [] with open(file_path, 'r', encoding='utf-8') as f: lines = f.readlines() for line in lines: - if line.startswith(".. _cn"): - line = re.sub(".. _", "", line) - line = re.sub(":", "", line) - list.append(line.rstrip()) - return list + line = re.search(".. _([a-zA-Z_]+)", line) + if line: + api_labels_in_one_file.append(line.group(1)) + return api_labels_in_one_file # api doc for checking -def test_ornot(file): - if ( +def should_test(file): + return ( file.endswith("_cn.rst") and (file not in ["Overview_cn.rst", "index_cn.rst"]) - and file.startswith("api") - ): - return True - return False + and file.startswith(API) + ) def pipline(rootdir, files): for file in files: - if test_ornot(file): + if should_test(file): if check_api_label(rootdir, file): pass else: print("error:", file) - list = traverse_api_label(rootdir) + valid_api_labels = find_all_api_labels_in_dir(rootdir) for file in files: - with open(rootdir + file, 'r', encoding='utf-8') as f: + with open(Path(rootdir) / file, 'r', encoding='utf-8') as f: pattern = f.read() matches = re.findall(r":ref:`([^`]+)`", pattern) - if matches: - for match in matches: - if match.startswith('cn'): - if match not in list: - print(rootdir + file, 'ref' + match, 'error') - else: - out = re.search("<(.*?)>", match) - if out and out.group(1).startswith("cn"): - if out.group(1) not in list: - print(rootdir + file, 'ref' + match, 'error') + for match in matches: + api_label = match + if api_label_match := re.math(r".+<(?P.+?)>", api_label): + api_label = api_label_match.group("api_label") + if api_label.startwith('cn_') and api_label not in valid_api_labels: + logger.error( + f"Found api label {api_label} in {rootdir}/{file}, but it is not a valid api label, please re-check it!" + ) + sys.exit(1) + + +def parse_args(): + """ + Parse input arguments + """ + parser = argparse.ArgumentParser(description='cn api_label checking') + parser.add_argument( + 'rootdir', + help='the dir DOCROOT', + type=str, + default='/FluidDoc/docs/', + ) + parser.add_argument( + 'apiroot', + type=str, + help='the dir APIROOT', + default='/FluidDoc/docs/api/', + ) + parser.add_argument( + 'need_check_cn_doc_files', + type=str, + nargs='+', + help='files need to check', + default='/FluidDoc/docs/api/', + ) + if len(sys.argv) == 2: + parser.print_help() + sys.exit(1) + + args = parser.parse_args() + return args if __name__ == "__main__": - pipline(sys.argv[1], sys.argv[2:]) + args = parse_args() + API = args.apiroot.removeprefix(args.rootdir + '/') + pipline(args.rootdir, args.need_check_cn_doc_files) From 214eb6352d7937637d7ec24a28d49473ec974c06 Mon Sep 17 00:00:00 2001 From: ooooo <3164076421@qq.com> Date: Sat, 14 Oct 2023 11:33:52 +0800 Subject: [PATCH 03/29] unify path with pathlib --- ci_scripts/check_api_label_cn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index 3ebf59cecb3..88d3a4d49d8 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -43,8 +43,8 @@ def find_all_api_labels_in_dir(rootdir): all_api_labels = [] for root, dirs, files in os.walk(rootdir + API): for file in files: - real_path = os.path.join(root, file) - path = real_path.removeprefix(rootdir) + real_path = Path(root) / file + path = str(real_path).removeprefix(rootdir) if should_test(path): for label in find_api_labels_in_one_file(real_path): all_api_labels.append(label) From 7a23c00c2f9b7789a0fa1f38f505d933862326f2 Mon Sep 17 00:00:00 2001 From: ooooo <3164076421@qq.com> Date: Mon, 16 Oct 2023 12:25:34 +0800 Subject: [PATCH 04/29] fix --- ci_scripts/check_api_label_cn.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index 88d3a4d49d8..7542c0d20cc 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -24,9 +24,7 @@ def check_api_label(rootdir, file): real_file = Path(rootdir) / file with open(real_file, 'r', encoding='utf-8') as f: first_line = f.readline() - if first_line == generate_en_label_by_path(file): - return True - return False + return first_line == generate_en_label_by_path(file) # path -> api_label (the first line's style) @@ -45,9 +43,10 @@ def find_all_api_labels_in_dir(rootdir): for file in files: real_path = Path(root) / file path = str(real_path).removeprefix(rootdir) - if should_test(path): - for label in find_api_labels_in_one_file(real_path): - all_api_labels.append(label) + if not should_test(path): + continue + for label in find_api_labels_in_one_file(real_path): + all_api_labels.append(label) return all_api_labels @@ -58,8 +57,9 @@ def find_api_labels_in_one_file(file_path): lines = f.readlines() for line in lines: line = re.search(".. _([a-zA-Z_]+)", line) - if line: - api_labels_in_one_file.append(line.group(1)) + if not line: + continue + api_labels_in_one_file.append(line.group(1)) return api_labels_in_one_file @@ -74,11 +74,11 @@ def should_test(file): def pipline(rootdir, files): for file in files: - if should_test(file): - if check_api_label(rootdir, file): - pass - else: - print("error:", file) + if should_test(file) and not check_api_label(rootdir, file): + logger.error( + f"The first line in {rootdir}/{file} is not avaiable, please re-check it!" + ) + sys.exit(1) valid_api_labels = find_all_api_labels_in_dir(rootdir) for file in files: with open(Path(rootdir) / file, 'r', encoding='utf-8') as f: @@ -119,10 +119,6 @@ def parse_args(): help='files need to check', default='/FluidDoc/docs/api/', ) - if len(sys.argv) == 2: - parser.print_help() - sys.exit(1) - args = parser.parse_args() return args From 8e3fe34b3f895e6fee40905eecb095ac55da05d7 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Tue, 17 Oct 2023 16:19:47 +0800 Subject: [PATCH 05/29] test ci --- docs/api/paddle/audio/Overview_cn.rst | 1 + docs/api/paddle/audio/datasets/TESS_cn.rst | 2 +- docs/api/paddle/audio/load_cn.rst | 2 +- docs/guides/06_distributed_training/data_parallel/amp_cn.rst | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/api/paddle/audio/Overview_cn.rst b/docs/api/paddle/audio/Overview_cn.rst index 18f8ecd124e..31edb5673fd 100644 --- a/docs/api/paddle/audio/Overview_cn.rst +++ b/docs/api/paddle/audio/Overview_cn.rst @@ -4,6 +4,7 @@ paddle.audio --------------------- + paddle.audio 目录是飞桨在语音领域的高层 API。具体如下: - :ref:`音频特征相关 API ` diff --git a/docs/api/paddle/audio/datasets/TESS_cn.rst b/docs/api/paddle/audio/datasets/TESS_cn.rst index 80052cca646..4e24614c780 100644 --- a/docs/api/paddle/audio/datasets/TESS_cn.rst +++ b/docs/api/paddle/audio/datasets/TESS_cn.rst @@ -20,7 +20,7 @@ TESS 返回 ::::::::: -:ref:`cn_api_paddle_io_Dataset`,TESS 数据集实例。 +:ref:`cn_api_paddle_io_Datase`,TESS 数据集实例。 代码示例 ::::::::: diff --git a/docs/api/paddle/audio/load_cn.rst b/docs/api/paddle/audio/load_cn.rst index ceeecdab422..2f1cbec0f73 100644 --- a/docs/api/paddle/audio/load_cn.rst +++ b/docs/api/paddle/audio/load_cn.rst @@ -1,4 +1,4 @@ -.. _cn_api_paddle_audio_load: +.. _cn_api_paddle_audio_loa: load ------------------------------- diff --git a/docs/guides/06_distributed_training/data_parallel/amp_cn.rst b/docs/guides/06_distributed_training/data_parallel/amp_cn.rst index ccf59c196d8..2f45e362bd0 100644 --- a/docs/guides/06_distributed_training/data_parallel/amp_cn.rst +++ b/docs/guides/06_distributed_training/data_parallel/amp_cn.rst @@ -46,7 +46,7 @@ 二、动态图操作实践 --------------------------- -使用飞桨框架提供的 API:\ ``paddle.amp.auto_cast``\ 和\ ``paddle.amp.GradScaler``\ 能够实现动态图的自动混合精度训练,即在相关 OP 的计算中,自动选择 FP16 或 FP32 格式计算。开启 AMP 模式后,使用 FP16 与 FP32 进行计算的 OP 列表可以参见 :ref:`cn_overview_amp` 。 +使用飞桨框架提供的 API:\ ``paddle.amp.auto_cast``\ 和\ ``paddle.amp.GradScaler``\ 能够实现动态图的自动混合精度训练,即在相关 OP 的计算中,自动选择 FP16 或 FP32 格式计算。开启 AMP 模式后,使用 FP16 与 FP32 进行计算的 OP 列表可以参见 :ref:`cn_api_paddle_geometric_reindex_graph` 。 2.1 具体示例 ^^^^^^^^^^^^^^^^^^ From fb359a053bff8f2328009c30a8a7bda7e81345f0 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Tue, 17 Oct 2023 17:54:55 +0800 Subject: [PATCH 06/29] fix bugs --- ci_scripts/check_api_label_cn.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index 7542c0d20cc..3123e032539 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -67,7 +67,8 @@ def find_api_labels_in_one_file(file_path): def should_test(file): return ( file.endswith("_cn.rst") - and (file not in ["Overview_cn.rst", "index_cn.rst"]) + and not file.endswith("Overview_cn.rst") + and not file.endswith("index_cn.rs") and file.startswith(API) ) From 2a741cc4c19b2057a8d93a8a4caaad96a48b0c96 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Wed, 18 Oct 2023 07:42:13 +0800 Subject: [PATCH 07/29] fix --- ci_scripts/check_api_label_cn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index 3123e032539..bd62f21c374 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -56,7 +56,7 @@ def find_api_labels_in_one_file(file_path): with open(file_path, 'r', encoding='utf-8') as f: lines = f.readlines() for line in lines: - line = re.search(".. _([a-zA-Z_]+)", line) + line = re.search(".. _([a-zA-Z0-9_]+)", line) if not line: continue api_labels_in_one_file.append(line.group(1)) @@ -68,7 +68,7 @@ def should_test(file): return ( file.endswith("_cn.rst") and not file.endswith("Overview_cn.rst") - and not file.endswith("index_cn.rs") + and not file.endswith("index_cn.rst") and file.startswith(API) ) From aaf28276b5e036b15103b237a58be01b6262925d Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Wed, 18 Oct 2023 19:59:40 +0800 Subject: [PATCH 08/29] fix --- ci_scripts/check_api_cn.sh | 7 ++++++- ci_scripts/check_api_label_cn.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ci_scripts/check_api_cn.sh b/ci_scripts/check_api_cn.sh index 1a87d1923a3..c3312170725 100644 --- a/ci_scripts/check_api_cn.sh +++ b/ci_scripts/check_api_cn.sh @@ -45,5 +45,10 @@ if [ $? -ne 0 ];then exit 1 fi +if [ -z ${BRANCH} ]; then + BRANCH="develop" +fi + +all_git_files = `git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'` echo "Run API_LABEL Checking" -python check_api_label_cn.py ${DOCROOT} ${APIROOT} $need_check_cn_doc_files \ No newline at end of file +python check_api_label_cn.py ${DOCROOT} ${APIROOT} $all_git_files \ No newline at end of file diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index bd62f21c374..8c7368bb646 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -107,6 +107,7 @@ def parse_args(): type=str, default='/FluidDoc/docs/', ) + parser.add_argument( 'apiroot', type=str, @@ -118,7 +119,7 @@ def parse_args(): type=str, nargs='+', help='files need to check', - default='/FluidDoc/docs/api/', + default='', ) args = parser.parse_args() return args From d5dd8a56c71a7c67a8fbfdf3585f169a999dd395 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Wed, 18 Oct 2023 22:07:33 +0800 Subject: [PATCH 09/29] fix --- ci_scripts/check_api_cn.sh | 2 +- ci_scripts/check_api_label_cn.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci_scripts/check_api_cn.sh b/ci_scripts/check_api_cn.sh index c3312170725..253b437d74c 100644 --- a/ci_scripts/check_api_cn.sh +++ b/ci_scripts/check_api_cn.sh @@ -51,4 +51,4 @@ fi all_git_files = `git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'` echo "Run API_LABEL Checking" -python check_api_label_cn.py ${DOCROOT} ${APIROOT} $all_git_files \ No newline at end of file +python check_api_label_cn.py ${DOCROOT} ${APIROOT} ${all_git_files} \ No newline at end of file diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index 8c7368bb646..4f5955831c1 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -115,7 +115,7 @@ def parse_args(): default='/FluidDoc/docs/api/', ) parser.add_argument( - 'need_check_cn_doc_files', + 'all_git_files', type=str, nargs='+', help='files need to check', @@ -128,4 +128,4 @@ def parse_args(): if __name__ == "__main__": args = parse_args() API = args.apiroot.removeprefix(args.rootdir + '/') - pipline(args.rootdir, args.need_check_cn_doc_files) + pipline(args.rootdir, args.all_git_files) From e8d48064cd04af5a8f110602ad058d102cbe4696 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 11:16:57 +0800 Subject: [PATCH 10/29] fix args --- ci_scripts/check_api_cn.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci_scripts/check_api_cn.sh b/ci_scripts/check_api_cn.sh index 253b437d74c..2180008c45f 100644 --- a/ci_scripts/check_api_cn.sh +++ b/ci_scripts/check_api_cn.sh @@ -51,4 +51,4 @@ fi all_git_files = `git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'` echo "Run API_LABEL Checking" -python check_api_label_cn.py ${DOCROOT} ${APIROOT} ${all_git_files} \ No newline at end of file +python check_api_label_cn.py ${DOCROOT} ${APIROOT} "$all_git_files" \ No newline at end of file From 936a71abefb60fed98def13e6c4011049e0e14ed Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 13:04:49 +0800 Subject: [PATCH 11/29] try --- ci_scripts/check_api_cn.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci_scripts/check_api_cn.sh b/ci_scripts/check_api_cn.sh index 2180008c45f..91e279bbde5 100644 --- a/ci_scripts/check_api_cn.sh +++ b/ci_scripts/check_api_cn.sh @@ -49,6 +49,7 @@ if [ -z ${BRANCH} ]; then BRANCH="develop" fi -all_git_files = `git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'` +all_git_files = $(`git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'`) +echo $all_git_files echo "Run API_LABEL Checking" python check_api_label_cn.py ${DOCROOT} ${APIROOT} "$all_git_files" \ No newline at end of file From 19bd30264d55deca0627e8b410b59e6ab6775b35 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 13:57:47 +0800 Subject: [PATCH 12/29] fix --- ci_scripts/check_api_cn.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci_scripts/check_api_cn.sh b/ci_scripts/check_api_cn.sh index 91e279bbde5..f72e49ea965 100644 --- a/ci_scripts/check_api_cn.sh +++ b/ci_scripts/check_api_cn.sh @@ -49,7 +49,7 @@ if [ -z ${BRANCH} ]; then BRANCH="develop" fi -all_git_files = $(`git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'`) +all_git_files=`git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'` echo $all_git_files echo "Run API_LABEL Checking" python check_api_label_cn.py ${DOCROOT} ${APIROOT} "$all_git_files" \ No newline at end of file From 9cb0ef7706e70a4b1423afb6d5e66c39813e6844 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 14:51:18 +0800 Subject: [PATCH 13/29] fix --- ci_scripts/check_api_cn.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci_scripts/check_api_cn.sh b/ci_scripts/check_api_cn.sh index f72e49ea965..172a42d730c 100644 --- a/ci_scripts/check_api_cn.sh +++ b/ci_scripts/check_api_cn.sh @@ -52,4 +52,4 @@ fi all_git_files=`git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'` echo $all_git_files echo "Run API_LABEL Checking" -python check_api_label_cn.py ${DOCROOT} ${APIROOT} "$all_git_files" \ No newline at end of file +python check_api_label_cn.py ${DOCROOT} ${APIROOT} $all_git_files \ No newline at end of file From b455ebc0a45046e0c9d62e237644df4a66b88e18 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 15:37:17 +0800 Subject: [PATCH 14/29] test_00 --- ci_scripts/check_api_label_cn.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index 4f5955831c1..eee20e3fc56 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -24,6 +24,8 @@ def check_api_label(rootdir, file): real_file = Path(rootdir) / file with open(real_file, 'r', encoding='utf-8') as f: first_line = f.readline() + print(first_line) + print(generate_en_label_by_path(file)) return first_line == generate_en_label_by_path(file) From d9aedace62a020b57c4e4379158fae8b1ed5efc8 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 16:44:43 +0800 Subject: [PATCH 15/29] fix --- ci_scripts/check_api_label_cn.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index eee20e3fc56..c24d88b4175 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -31,7 +31,7 @@ def check_api_label(rootdir, file): # path -> api_label (the first line's style) def generate_en_label_by_path(file): - result = file.removeprefix(API) + # result = file.removeprefix(API) result = result.removesuffix('_cn.rst') result = result.replace('/', '_') result = f'.. _cn_{result}:' @@ -91,7 +91,10 @@ def pipline(rootdir, files): api_label = match if api_label_match := re.math(r".+<(?P.+?)>", api_label): api_label = api_label_match.group("api_label") - if api_label.startwith('cn_') and api_label not in valid_api_labels: + if ( + api_label.startwith('cn_api_paddle') + and api_label not in valid_api_labels + ): logger.error( f"Found api label {api_label} in {rootdir}/{file}, but it is not a valid api label, please re-check it!" ) From bd74f6a258ecbf182e8384ea271d836f84cec4ac Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 18:04:38 +0800 Subject: [PATCH 16/29] fix --- ci_scripts/check_api_label_cn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index c24d88b4175..b74f2bf15b0 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -32,7 +32,7 @@ def check_api_label(rootdir, file): # path -> api_label (the first line's style) def generate_en_label_by_path(file): # result = file.removeprefix(API) - result = result.removesuffix('_cn.rst') + result = file.removesuffix('_cn.rst') result = result.replace('/', '_') result = f'.. _cn_{result}:' return result From b9419fa27819a57cae569ed8be83d1bd398730c1 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 19:10:47 +0800 Subject: [PATCH 17/29] fix --- ci_scripts/check_api_label_cn.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index b74f2bf15b0..652922cc8c6 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -23,7 +23,7 @@ def check_api_label(rootdir, file): real_file = Path(rootdir) / file with open(real_file, 'r', encoding='utf-8') as f: - first_line = f.readline() + first_line = f.readline().strip() print(first_line) print(generate_en_label_by_path(file)) return first_line == generate_en_label_by_path(file) @@ -124,7 +124,6 @@ def parse_args(): type=str, nargs='+', help='files need to check', - default='', ) args = parser.parse_args() return args From 62e02a92a588b3f1110060584399282a45782df4 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 20:03:15 +0800 Subject: [PATCH 18/29] test1 --- docs/api/paddle/audio/load_cn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/paddle/audio/load_cn.rst b/docs/api/paddle/audio/load_cn.rst index 2f1cbec0f73..ceeecdab422 100644 --- a/docs/api/paddle/audio/load_cn.rst +++ b/docs/api/paddle/audio/load_cn.rst @@ -1,4 +1,4 @@ -.. _cn_api_paddle_audio_loa: +.. _cn_api_paddle_audio_load: load ------------------------------- From 8f150ef0a6d8dd9250ac1b1e04cc99ddade8befd Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 21:13:43 +0800 Subject: [PATCH 19/29] fix --- ci_scripts/check_api_label_cn.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index 652922cc8c6..b1fe8fe1a38 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -77,7 +77,9 @@ def should_test(file): def pipline(rootdir, files): for file in files: - if should_test(file) and not check_api_label(rootdir, file): + if not should_test(file): + continue + if not check_api_label(rootdir, file): logger.error( f"The first line in {rootdir}/{file} is not avaiable, please re-check it!" ) From 6d0567d5386821d7228ba0be83c0d45e64dc5b37 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 21:18:26 +0800 Subject: [PATCH 20/29] fix --- ci_scripts/check_api_label_cn.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index b1fe8fe1a38..dc2f0851243 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -86,6 +86,8 @@ def pipline(rootdir, files): sys.exit(1) valid_api_labels = find_all_api_labels_in_dir(rootdir) for file in files: + if not file.endswith('.rst'): + continue with open(Path(rootdir) / file, 'r', encoding='utf-8') as f: pattern = f.read() matches = re.findall(r":ref:`([^`]+)`", pattern) From a3217f09c82d250fe200403f1939318bbd8aae9f Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 21:24:11 +0800 Subject: [PATCH 21/29] update --- ci_scripts/check_api_label_cn.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index dc2f0851243..2b095bad286 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -77,9 +77,7 @@ def should_test(file): def pipline(rootdir, files): for file in files: - if not should_test(file): - continue - if not check_api_label(rootdir, file): + if should_test(file) and not check_api_label(rootdir, file): logger.error( f"The first line in {rootdir}/{file} is not avaiable, please re-check it!" ) From ad8ead8826272dc80060c6da46518f677ede3ca8 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 21:52:20 +0800 Subject: [PATCH 22/29] fix --- ci_scripts/check_api_label_cn.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index 2b095bad286..1545b857b7f 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -91,7 +91,9 @@ def pipline(rootdir, files): matches = re.findall(r":ref:`([^`]+)`", pattern) for match in matches: api_label = match - if api_label_match := re.math(r".+<(?P.+?)>", api_label): + if api_label_match := re.match( + r".+<(?P.+?)>", api_label + ): api_label = api_label_match.group("api_label") if ( api_label.startwith('cn_api_paddle') From f1f23d617120b659523c00e1a1a5a05cdf0b4c86 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 22:21:42 +0800 Subject: [PATCH 23/29] fix --- ci_scripts/check_api_label_cn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index 1545b857b7f..3137c3a2d62 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -96,7 +96,7 @@ def pipline(rootdir, files): ): api_label = api_label_match.group("api_label") if ( - api_label.startwith('cn_api_paddle') + api_label.startswith('cn_api_paddle') and api_label not in valid_api_labels ): logger.error( From 8ba9ab0bc9e4f1d47e1c3063483e1081296aaa07 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Thu, 19 Oct 2023 22:56:58 +0800 Subject: [PATCH 24/29] test --- docs/api/paddle/audio/datasets/TESS_cn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/paddle/audio/datasets/TESS_cn.rst b/docs/api/paddle/audio/datasets/TESS_cn.rst index 4e24614c780..80052cca646 100644 --- a/docs/api/paddle/audio/datasets/TESS_cn.rst +++ b/docs/api/paddle/audio/datasets/TESS_cn.rst @@ -20,7 +20,7 @@ TESS 返回 ::::::::: -:ref:`cn_api_paddle_io_Datase`,TESS 数据集实例。 +:ref:`cn_api_paddle_io_Dataset`,TESS 数据集实例。 代码示例 ::::::::: From 06b04a3d7d75e022f3c03e700db03779e4fd44f5 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Fri, 20 Oct 2023 11:16:58 +0800 Subject: [PATCH 25/29] test2 --- docs/api/paddle/audio/Overview_cn.rst | 1 - docs/guides/06_distributed_training/data_parallel/amp_cn.rst | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/api/paddle/audio/Overview_cn.rst b/docs/api/paddle/audio/Overview_cn.rst index 31edb5673fd..18f8ecd124e 100644 --- a/docs/api/paddle/audio/Overview_cn.rst +++ b/docs/api/paddle/audio/Overview_cn.rst @@ -4,7 +4,6 @@ paddle.audio --------------------- - paddle.audio 目录是飞桨在语音领域的高层 API。具体如下: - :ref:`音频特征相关 API ` diff --git a/docs/guides/06_distributed_training/data_parallel/amp_cn.rst b/docs/guides/06_distributed_training/data_parallel/amp_cn.rst index 2f45e362bd0..2e27b482610 100644 --- a/docs/guides/06_distributed_training/data_parallel/amp_cn.rst +++ b/docs/guides/06_distributed_training/data_parallel/amp_cn.rst @@ -46,7 +46,7 @@ 二、动态图操作实践 --------------------------- -使用飞桨框架提供的 API:\ ``paddle.amp.auto_cast``\ 和\ ``paddle.amp.GradScaler``\ 能够实现动态图的自动混合精度训练,即在相关 OP 的计算中,自动选择 FP16 或 FP32 格式计算。开启 AMP 模式后,使用 FP16 与 FP32 进行计算的 OP 列表可以参见 :ref:`cn_api_paddle_geometric_reindex_graph` 。 +使用飞桨框架提供的 API:\ ``paddle.amp.auto_cast``\ 和\ ``paddle.amp.GradScaler``\ 能够实现动态图的自动混合精度训练,即在相关 OP 的计算中,自动选择 FP16 或 FP32 格式计算。开启 AMP 模式后,使用 FP16 与 FP32 进行计算的 OP 列表可以参见 :ref:`cn_api_paddle_geometric_reindex_grap` 。 2.1 具体示例 ^^^^^^^^^^^^^^^^^^ From e81b9a65b718d783bbab0e99033d9d1f044bf06e Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Fri, 20 Oct 2023 12:55:56 +0800 Subject: [PATCH 26/29] change checking location and test --- ci_scripts/check_api_cn.sh | 16 ++++++++-------- ci_scripts/check_api_label_cn.py | 1 + ci_scripts/check_api_label_cn.sh | 24 ++++++++++++++++++++++++ ci_scripts/ci_start.sh | 6 ++++++ 4 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 ci_scripts/check_api_label_cn.sh diff --git a/ci_scripts/check_api_cn.sh b/ci_scripts/check_api_cn.sh index 172a42d730c..b7c779e16fe 100644 --- a/ci_scripts/check_api_cn.sh +++ b/ci_scripts/check_api_cn.sh @@ -45,11 +45,11 @@ if [ $? -ne 0 ];then exit 1 fi -if [ -z ${BRANCH} ]; then - BRANCH="develop" -fi - -all_git_files=`git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'` -echo $all_git_files -echo "Run API_LABEL Checking" -python check_api_label_cn.py ${DOCROOT} ${APIROOT} $all_git_files \ No newline at end of file +# if [ -z ${BRANCH} ]; then +# BRANCH="develop" +# fi + +# all_git_files=`git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'` +# echo $all_git_files +# echo "Run API_LABEL Checking" +# python check_api_label_cn.py ${DOCROOT} ${APIROOT} $all_git_files \ No newline at end of file diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index 3137c3a2d62..a15e0da72c7 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -103,6 +103,7 @@ def pipline(rootdir, files): f"Found api label {api_label} in {rootdir}/{file}, but it is not a valid api label, please re-check it!" ) sys.exit(1) + print("All api_label check success in PR !") def parse_args(): diff --git a/ci_scripts/check_api_label_cn.sh b/ci_scripts/check_api_label_cn.sh new file mode 100644 index 00000000000..2d6b548dac7 --- /dev/null +++ b/ci_scripts/check_api_label_cn.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -x + +FLUIDDOCDIR=${FLUIDDOCDIR:=/FluidDoc} + +DOCROOT=${FLUIDDOCDIR}/docs/ +APIROOT=${DOCROOT}/api/ + +SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" +source ${SCRIPT_DIR}/utils.sh + +if [ -z ${BRANCH} ]; then + BRANCH="develop" +fi + +all_git_files=`git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'` +echo $all_git_files +echo "Run API_LABEL Checking" +python check_api_label_cn.py ${DOCROOT} ${APIROOT} $all_git_files + +if [ $? -ne 0 ];then + echo "ERROR: api_label is not correct, please check api_label in the above files" + exit 1 +fi \ No newline at end of file diff --git a/ci_scripts/ci_start.sh b/ci_scripts/ci_start.sh index 30508f0a0e8..37966a3c27c 100644 --- a/ci_scripts/ci_start.sh +++ b/ci_scripts/ci_start.sh @@ -122,6 +122,12 @@ else fi fi +# 5 Chinese api_label check +/bin/bash -x ${DIR_PATH}/check_api_label_cn.sh +if [ $? -ne 0];then + EXIT_CODE=1 +fi + if [ ${EXIT_CODE} -ne 0 ]; then set +x echo "==========================================================================================" From b52661f22f96479110caa42cc5b065dcb3c28ad7 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Fri, 20 Oct 2023 13:37:58 +0800 Subject: [PATCH 27/29] finally test --- ci_scripts/check_api_cn.sh | 14 +------------- ci_scripts/check_api_label_cn.py | 1 - ci_scripts/ci_start.sh | 4 ++-- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/ci_scripts/check_api_cn.sh b/ci_scripts/check_api_cn.sh index b7c779e16fe..668f9047e32 100644 --- a/ci_scripts/check_api_cn.sh +++ b/ci_scripts/check_api_cn.sh @@ -5,9 +5,6 @@ FLUIDDOCDIR=${FLUIDDOCDIR:=/FluidDoc} OUTPUTDIR=${OUTPUTDIR:=/docs} VERSIONSTR=${VERSIONSTR:=develop} -DOCROOT=${FLUIDDOCDIR}/docs/ -APIROOT=${DOCROOT}/api/ - SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" source ${SCRIPT_DIR}/utils.sh @@ -43,13 +40,4 @@ python check_copy_from_parsed_into_sample_code.py "${OUTPUTDIR}/zh/${VERSIONSTR} if [ $? -ne 0 ];then echo "ERROR: Exist COPY-FROM has not been parsed into sample code, please check COPY-FROM in the above files" exit 1 -fi - -# if [ -z ${BRANCH} ]; then -# BRANCH="develop" -# fi - -# all_git_files=`git diff --name-only --diff-filter=ACMR upstream/${BRANCH} | sed 's#docs/##g'` -# echo $all_git_files -# echo "Run API_LABEL Checking" -# python check_api_label_cn.py ${DOCROOT} ${APIROOT} $all_git_files \ No newline at end of file +fi \ No newline at end of file diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index a15e0da72c7..f475dbe1b9c 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -31,7 +31,6 @@ def check_api_label(rootdir, file): # path -> api_label (the first line's style) def generate_en_label_by_path(file): - # result = file.removeprefix(API) result = file.removesuffix('_cn.rst') result = result.replace('/', '_') result = f'.. _cn_{result}:' diff --git a/ci_scripts/ci_start.sh b/ci_scripts/ci_start.sh index 37966a3c27c..d045c168bed 100644 --- a/ci_scripts/ci_start.sh +++ b/ci_scripts/ci_start.sh @@ -124,7 +124,7 @@ fi # 5 Chinese api_label check /bin/bash -x ${DIR_PATH}/check_api_label_cn.sh -if [ $? -ne 0];then +if [ $? -ne 0 ];then EXIT_CODE=1 fi @@ -137,7 +137,7 @@ if [ ${EXIT_CODE} -ne 0 ]; then exit ${EXIT_CODE} fi -# 5 Approval check +# 6 Approval check /bin/bash ${DIR_PATH}/checkapproval.sh if [ $? -ne 0 ];then exit 1 From f433b520444837be0dd15d4804f77eff82352758 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Sun, 22 Oct 2023 10:48:39 +0800 Subject: [PATCH 28/29] fix --- ci_scripts/check_api_label_cn.py | 6 ++---- .../guides/06_distributed_training/data_parallel/amp_cn.rst | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index f475dbe1b9c..cd03b941797 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -24,8 +24,6 @@ def check_api_label(rootdir, file): real_file = Path(rootdir) / file with open(real_file, 'r', encoding='utf-8') as f: first_line = f.readline().strip() - print(first_line) - print(generate_en_label_by_path(file)) return first_line == generate_en_label_by_path(file) @@ -74,7 +72,7 @@ def should_test(file): ) -def pipline(rootdir, files): +def run_cn_api_lable_checking(rootdir, files): for file in files: if should_test(file) and not check_api_label(rootdir, file): logger.error( @@ -136,4 +134,4 @@ def parse_args(): if __name__ == "__main__": args = parse_args() API = args.apiroot.removeprefix(args.rootdir + '/') - pipline(args.rootdir, args.all_git_files) + run_cn_api_lable_checking(args.rootdir, args.all_git_files) diff --git a/docs/guides/06_distributed_training/data_parallel/amp_cn.rst b/docs/guides/06_distributed_training/data_parallel/amp_cn.rst index 2e27b482610..ccf59c196d8 100644 --- a/docs/guides/06_distributed_training/data_parallel/amp_cn.rst +++ b/docs/guides/06_distributed_training/data_parallel/amp_cn.rst @@ -46,7 +46,7 @@ 二、动态图操作实践 --------------------------- -使用飞桨框架提供的 API:\ ``paddle.amp.auto_cast``\ 和\ ``paddle.amp.GradScaler``\ 能够实现动态图的自动混合精度训练,即在相关 OP 的计算中,自动选择 FP16 或 FP32 格式计算。开启 AMP 模式后,使用 FP16 与 FP32 进行计算的 OP 列表可以参见 :ref:`cn_api_paddle_geometric_reindex_grap` 。 +使用飞桨框架提供的 API:\ ``paddle.amp.auto_cast``\ 和\ ``paddle.amp.GradScaler``\ 能够实现动态图的自动混合精度训练,即在相关 OP 的计算中,自动选择 FP16 或 FP32 格式计算。开启 AMP 模式后,使用 FP16 与 FP32 进行计算的 OP 列表可以参见 :ref:`cn_overview_amp` 。 2.1 具体示例 ^^^^^^^^^^^^^^^^^^ From cfb90f35b84d41dd245850b25add8aadde1151d3 Mon Sep 17 00:00:00 2001 From: ooo oo <3164076421@qq.com> Date: Sun, 22 Oct 2023 14:06:43 +0800 Subject: [PATCH 29/29] label --- ci_scripts/check_api_label_cn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci_scripts/check_api_label_cn.py b/ci_scripts/check_api_label_cn.py index cd03b941797..012dfe5f9ef 100644 --- a/ci_scripts/check_api_label_cn.py +++ b/ci_scripts/check_api_label_cn.py @@ -72,7 +72,7 @@ def should_test(file): ) -def run_cn_api_lable_checking(rootdir, files): +def run_cn_api_label_checking(rootdir, files): for file in files: if should_test(file) and not check_api_label(rootdir, file): logger.error( @@ -134,4 +134,4 @@ def parse_args(): if __name__ == "__main__": args = parse_args() API = args.apiroot.removeprefix(args.rootdir + '/') - run_cn_api_lable_checking(args.rootdir, args.all_git_files) + run_cn_api_label_checking(args.rootdir, args.all_git_files)