Skip to content

Commit 067e840

Browse files
committed
Merge branch 'cuda_apis_2' of github.com:fxyfxy777/docs into cuda_apis_2
2 parents a8da6fc + ed4794c commit 067e840

File tree

326 files changed

+3938
-3722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

326 files changed

+3938
-3722
lines changed

_typos.toml

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -25,64 +25,19 @@ arange = "arange"
2525
unsupport = "unsupport"
2626
Nervana = "Nervana"
2727
datas = "datas"
28+
feeded = "feeded"
2829

2930
# These words need to be fixed
30-
Creenshot = "Creenshot"
3131
Learing = "Learing"
32-
Moible = "Moible"
3332
Operaton = "Operaton"
3433
Optimizaing = "Optimizaing"
3534
Optimzier = "Optimzier"
3635
Setment = "Setment"
37-
Similarily = "Similarily"
3836
Simle = "Simle"
3937
Sovler = "Sovler"
40-
Successed = "Successed"
41-
desgin = "desgin"
42-
desginated = "desginated"
43-
desigin = "desigin"
44-
determinated = "determinated"
45-
diffcult = "diffcult"
46-
dimention = "dimention"
47-
dimentions = "dimentions"
48-
dirrectories = "dirrectories"
49-
disucssion = "disucssion"
50-
feeded = "feeded"
51-
flaot = "flaot"
52-
fliters = "fliters"
53-
follwing = "follwing"
54-
formated = "formated"
55-
formater = "formater"
56-
forword = "forword"
57-
foward = "foward"
58-
functinal = "functinal"
59-
fundemental = "fundemental"
60-
funtion = "funtion"
61-
ilter = "ilter"
62-
inferface = "inferface"
63-
infor = "infor"
64-
instert = "instert"
65-
instrinsics = "instrinsics"
66-
interchangable = "interchangable"
67-
intializers = "intializers"
68-
intput = "intput"
69-
lable = "lable"
70-
learing = "learing"
71-
legth = "legth"
72-
lenth = "lenth"
73-
leran = "leran"
7438
libary = "libary"
75-
mantained = "mantained"
7639
matrics = "matrics"
77-
mdule = "mdule"
78-
mechnism = "mechnism"
79-
memeory = "memeory"
80-
memroy = "memroy"
81-
messege = "messege"
82-
metaphore = "metaphore"
8340
metrices = "metrices"
84-
muliply = "muliply"
85-
mulitplying = "mulitplying"
8641
mutbale = "mutbale"
8742
occurence = "occurence"
8843
opeartor = "opeartor"
@@ -93,11 +48,7 @@ outpu = "outpu"
9348
outpus = "outpus"
9449
overrided = "overrided"
9550
overwrited = "overwrited"
96-
porcess = "porcess"
97-
processer = "processer"
98-
sacle = "sacle"
9951
samle = "samle"
100-
satifies = "satifies"
10152
schedual = "schedual"
10253
secenarios = "secenarios"
10354
sematic = "sematic"

ci_scripts/CAPItools/utils_helper.py

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def decode(self):
219219
# 避免空函数解析
220220
self.init_func = self.class_name
221221

222-
self.functions_infor = []
222+
self.functions_info = []
223223
# Note: 未来可能在private也有函数
224224
# Note: 函数内构造函数可能解析有问题,需要后期查验
225225
self.class_function_number = len(self.class_dict["methods"]["public"])
@@ -267,7 +267,7 @@ def decode(self):
267267
"param_intro"
268268
][param_name]
269269

270-
self.functions_infor.append(
270+
self.functions_info.append(
271271
{
272272
"name": function_name,
273273
"doxygen": funcs_intro,
@@ -322,46 +322,48 @@ def create_and_write_file_cn(self, save_dir, language):
322322
)
323323
f.write(class_function_head_text)
324324

325-
for fun_infor in self.functions_infor:
326-
if fun_infor["template"] == "":
325+
for fun_info in self.functions_info:
326+
if fun_info["template"] == "":
327327
fun_name_and_intro_text = ""
328328
else:
329-
fun_name_and_intro_text = f"{fun_infor['template']}\n"
329+
fun_name_and_intro_text = f"{fun_info['template']}\n"
330330
fun_name_and_intro_text += (
331-
f"{fun_infor['name']}\n"
331+
f"{fun_info['name']}\n"
332332
+ "'''''''''''\n"
333-
+ f"{fun_infor['doxygen']}\n"
333+
+ f"{fun_info['doxygen']}\n"
334334
+ "\n"
335335
)
336336
f.write(fun_name_and_intro_text)
337337

338-
if fun_infor["note"] != "":
338+
if fun_info["note"] != "":
339339
fun_note_text = (
340-
"..note::\n" + f"\t{fun_infor['note']}\n" + "\n"
340+
"..note::\n" + f"\t{fun_info['note']}\n" + "\n"
341341
)
342342
f.write(fun_note_text)
343343

344-
if len(fun_infor["parameter"]) != 0:
344+
if len(fun_info["parameter"]) != 0:
345345
parameters_text = "**参数**\n" + "'''''''''''\n"
346346
f.write(parameters_text)
347-
for param in fun_infor["parameter"].keys():
347+
for param in fun_info["parameter"].keys():
348348
param_text = f"\t- **{param}**"
349-
if fun_infor["parameter"][param]["type"] != "":
350-
param_text += f" ({fun_infor['parameter'][param]['type']})"
351-
if fun_infor["parameter"][param]["intro"] != "":
352-
param_text += f" - {fun_infor['parameter'][param]['intro']}"
349+
if fun_info["parameter"][param]["type"] != "":
350+
param_text += (
351+
f" ({fun_info['parameter'][param]['type']})"
352+
)
353+
if fun_info["parameter"][param]["intro"] != "":
354+
param_text += f" - {fun_info['parameter'][param]['intro']}"
353355
param_text += "\n"
354356
f.write(param_text)
355357
f.write("\n")
356358

357359
if (
358-
fun_infor["returns"] != ""
359-
and "void" not in fun_infor["returns"]
360+
fun_info["returns"] != ""
361+
and "void" not in fun_info["returns"]
360362
):
361363
fun_return_text = (
362364
"**返回**\n"
363365
+ "'''''''''''\n"
364-
+ f"{fun_infor['returns']}\n"
366+
+ f"{fun_info['returns']}\n"
365367
+ "\n"
366368
)
367369
f.write(fun_return_text)
@@ -399,46 +401,48 @@ def create_and_write_file_en(self, save_dir, language):
399401
)
400402
f.write(class_function_head_text)
401403

402-
for fun_infor in self.functions_infor:
403-
if fun_infor["template"] == "":
404+
for fun_info in self.functions_info:
405+
if fun_info["template"] == "":
404406
fun_name_and_intro_text = ""
405407
else:
406-
fun_name_and_intro_text = f"{fun_infor['template']}\n"
408+
fun_name_and_intro_text = f"{fun_info['template']}\n"
407409
fun_name_and_intro_text += (
408-
f"{fun_infor['name']}\n"
410+
f"{fun_info['name']}\n"
409411
+ "'''''''''''\n"
410-
+ f"{fun_infor['doxygen']}\n"
412+
+ f"{fun_info['doxygen']}\n"
411413
+ "\n"
412414
)
413415
f.write(fun_name_and_intro_text)
414416

415-
if fun_infor["note"] != "":
417+
if fun_info["note"] != "":
416418
fun_note_text = (
417-
"..note::\n" + f"\t{fun_infor['note']}\n" + "\n"
419+
"..note::\n" + f"\t{fun_info['note']}\n" + "\n"
418420
)
419421
f.write(fun_note_text)
420422

421-
if len(fun_infor["parameter"]) != 0:
423+
if len(fun_info["parameter"]) != 0:
422424
parameters_text = "**Parameters**\n" + "'''''''''''\n"
423425
f.write(parameters_text)
424-
for param in fun_infor["parameter"].keys():
426+
for param in fun_info["parameter"].keys():
425427
param_text = f"\t- **{param}**"
426-
if fun_infor["parameter"][param]["type"] != "":
427-
param_text += f" ({fun_infor['parameter'][param]['type']})"
428-
if fun_infor["parameter"][param]["intro"] != "":
429-
param_text += f" - {fun_infor['parameter'][param]['intro']}"
428+
if fun_info["parameter"][param]["type"] != "":
429+
param_text += (
430+
f" ({fun_info['parameter'][param]['type']})"
431+
)
432+
if fun_info["parameter"][param]["intro"] != "":
433+
param_text += f" - {fun_info['parameter'][param]['intro']}"
430434
param_text += "\n"
431435
f.write(param_text)
432436
f.write("\n")
433437

434438
if (
435-
fun_infor["returns"] != ""
436-
and "void" not in fun_infor["returns"]
439+
fun_info["returns"] != ""
440+
and "void" not in fun_info["returns"]
437441
):
438442
fun_return_text = (
439443
"**Returns**\n"
440444
+ "'''''''''''\n"
441-
+ f"{fun_infor['returns']}\n"
445+
+ f"{fun_info['returns']}\n"
442446
+ "\n"
443447
)
444448
f.write(fun_return_text)

ci_scripts/hooks/pre-doc-compile.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,27 @@ else
120120
echo "ERROR: Generated API mapping file not found at $GENERATED_FILE"
121121
handle_failure
122122
fi
123+
124+
python "${APIMAPPING_ROOT}/tools/validate_api_difference_format.py"
125+
126+
# 获取上一条命令的退出状态码
127+
exit_code=$?
128+
129+
# 根据退出状态码决定后续操作
130+
if [ $exit_code -eq 0 ]; then
131+
echo "API DIFFERENCE FORMAT VALIDATE SUCCESS!"
132+
# 在这里继续添加您需要执行的命令
133+
else
134+
echo "ERROR: API DIFFERENCE FORMAT VALIDATE FAILURE! error code: $exit_code" >&2
135+
exit 1
136+
fi
137+
138+
python "${APIMAPPING_ROOT}/tools/validate_pytorch_api_mapping.py" --skip-url-check
139+
exit_code=$?
140+
141+
if [ $exit_code -eq 0 ]; then
142+
echo "PYTORCH API MAPPING VALIDATE SUCCESS!"
143+
else
144+
echo "ERROR: PYTORCH API MAPPING VALIDATE FAILURE! error code: $exit_code" >&2
145+
exit 1
146+
fi

docs/api/copy_codes_from_en_doc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def find_codeblock_needed(cf_info):
237237
return None
238238

239239

240-
def instert_codes_into_cn_rst_if_need(cnrstfilename):
240+
def insert_codes_into_cn_rst_if_need(cnrstfilename):
241241
"""
242242
Analyse the cn rst file, if need, extract code-blocks from en docstring.
243243
"""
@@ -290,7 +290,7 @@ def instert_codes_into_cn_rst_if_need(cnrstfilename):
290290

291291

292292
def filter_all_files(
293-
rootdir, ext="_cn.rst", action=instert_codes_into_cn_rst_if_need
293+
rootdir, ext="_cn.rst", action=insert_codes_into_cn_rst_if_need
294294
):
295295
"""
296296
find all the _en.html file, and do the action.

docs/api/paddle/compat/Overview_cn.rst

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,33 @@ PyTorch 兼容函数
1818
" :ref:`median <cn_api_paddle_compat_median>` ", "兼容版中位数,支持 dim/keepdim/out 签名"
1919
" :ref:`min <cn_api_paddle_compat_min>` ", "包含 `amin`、同时返回 values 及 indices 的轴向最小值、`minimum` 三种功能"
2020
" :ref:`nanmedian <cn_api_paddle_compat_nanmedian>` ", "忽略 NaN 的兼容版中位数,支持 dim/keepdim/out 签名"
21-
" :ref:`pad <cn_api_paddle_compat_pad>` ", "从最后一维度开始进行 padding、padding 正确兼容转换的填充函数"
2221
" :ref:`slogdet <cn_api_paddle_compat_slogdet>` ", "slogdet 函数"
23-
" :ref:`softmax <cn_api_paddle_compat_softmax>` ", "softmax 函数"
2422
" :ref:`sort <cn_api_paddle_compat_sort>` ", "同时返回 values 及 indices 的排序"
2523
" :ref:`split <cn_api_paddle_compat_split>` ", "允许非整除块大小输入的 Tensor 轴向切分"
2624

2725

28-
.. _about_compat_class:
26+
.. _about_compat_nn:
2927

30-
PyTorch 兼容模块
31-
::::::::::::::::::::
28+
PyTorch 兼容的 nn 模块
29+
::::::::::::::::::::::::::::::
3230

3331
.. csv-table::
3432
:header: "类名称", "类功能"
3533
:widths: 10, 30
3634

37-
" :ref:`Unfold <cn_api_paddle_compat_Unfold>` ", "允许 Tensor 输入的 ``paddle.nn.Unfold`` 兼容版本"
35+
" :ref:`Linear <cn_api_paddle_compat_nn_Linear>` ", "PyTorch 对齐的 ``paddle.nn.Linear`` 兼容版本"
36+
" :ref:`Unfold <cn_api_paddle_compat_nn_Unfold>` ", "允许 Tensor 输入的 ``paddle.nn.Unfold`` 兼容版本"
37+
38+
39+
.. _about_compat_nn_functional:
40+
41+
PyTorch 兼容的 nn.functional 模块
42+
::::::::::::::::::::::::::::::::::::::::
43+
44+
.. csv-table::
45+
:header: "函数名称", "函数功能"
46+
:widths: 10, 30
47+
48+
" :ref:`linear <cn_api_paddle_compat_nn_functional_linear>` ", "PyTorch 对齐的 ``paddle.nn.functional.linear`` 兼容版本"
49+
" :ref:`pad <cn_api_paddle_compat_nn_functional_pad>` ", "从最后一维度开始进行 padding、padding 正确兼容转换的填充函数"
50+
" :ref:`softmax <cn_api_paddle_compat_nn_functional_softmax>` ", "softmax 函数"

docs/api/paddle/compat/max_cn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ max
99

1010
使用前请详细参考:`【返回参数类型不一致】torch.max`_ 以确定是否使用此模块。
1111

12-
.. _【返回参数类型不一致】torch.max: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.max.html
12+
.. _【返回参数类型不一致】torch.max: https://www.paddlepaddle.org.cn/documentation/docs/en/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.max.html
1313

1414

1515
.. caution::

docs/api/paddle/compat/min_cn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ min
99

1010
使用前请详细参考:`【返回参数类型不一致】torch.min`_ 以确定是否使用此模块。
1111

12-
.. _【返回参数类型不一致】torch.min: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.min.html
12+
.. _【返回参数类型不一致】torch.min: https://www.paddlepaddle.org.cn/documentation/docs/en/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.min.html
1313

1414

1515
.. caution::
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.. _cn_api_paddle_compat_nn_Linear:
2+
3+
Linear
4+
-------------------------------
5+
6+
.. py:class:: paddle.compat.nn.Linear(in_features, out_features, bias, device=None, dtype=None)
7+
8+
PyTorch 兼容的 :ref:`cn_api_paddle_nn_Linear` 版本:
9+
10+
- 与 PyTorch 一致的数学意义:
11+
12+
.. math::
13+
14+
Out = XW^T + b
15+
16+
其中 :math:`W` 是权重张量, :math:`b` 是偏置张量, :math:`X` 是输入张量
17+
18+
- 与 PyTorch 一致的默认可视化方法: Kaiming normal 用于权重初始化,平均分布用于偏置初始化
19+
- 支持设定 ``Linear`` 的数据类型以及运行设备
20+
21+
使用前请详细参考:`【仅参数名不一致】torch.nn.Linear`_ 以确定是否使用此模块。
22+
23+
.. _【仅参数名不一致】torch.nn.Linear: https://www.paddlepaddle.org.cn/documentation/docs/en/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Linear.html
24+
25+
参数
26+
:::::::::::
27+
28+
- **in_features** (int) - 输入单元数。
29+
- **out_features** (int) - 输出单元数。
30+
- **bias** (bool, 可选) - 如果为 True,将创建偏置(一个形状为 :math:`[out\_features]` 的一维张量)并添加到输出。默认值 True。
31+
- **device** (PlaceLike, 可选) - 创建参数所在的设备。默认值为 None,表示默认 Paddle 设备。
32+
- **dtype** (DTypeLike, 可选) - 创建参数的数据类型。默认值为 None,并设置为 Linear 的默认数据类型(float32)。
33+
34+
形状
35+
:::::::::
36+
37+
- **输入** : 多维张量,形状为 :math:`[*, in\_features]` 。数据类型为 float16、float32、float64,默认为 float32。
38+
- **输出** : 多维张量,形状为 :math:`[*, out\_features]` 。数据类型与输入相同。
39+
40+
41+
42+
代码示例
43+
::::::::::::
44+
45+
COPY-FROM: paddle.compat.nn.Linear

0 commit comments

Comments
 (0)