From 8eb881e5ecd9af8a587522889d8850152d106624 Mon Sep 17 00:00:00 2001 From: co63oc Date: Sun, 23 Jul 2023 08:45:24 +0800 Subject: [PATCH 1/2] Add docs --- .../torch.nn.functional.gaussian_nll_loss.md | 26 ++++++++++++++ ...ad.profiler.profile.export_chrome_trace.md | 22 ++++++++++++ .../others/torch.special.i0e.md | 36 +++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.gaussian_nll_loss.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.autograd.profiler.profile.export_chrome_trace.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.special.i0e.md diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.gaussian_nll_loss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.gaussian_nll_loss.md new file mode 100644 index 00000000000..53c6974fba0 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.gaussian_nll_loss.md @@ -0,0 +1,26 @@ +## [仅参数名不一致]torch.nn.functional.gaussian_nll_loss + +### [torch.nn.functional.gaussian_nll_loss](https://pytorch.org/docs/stable/generated/torch.nn.functional.gaussian_nll_loss.html#torch.nn.functional.gaussian_nll_loss) + +```python +torch.nn.functional.gaussian_nll_loss(input, target, var, full=False, eps=1e-06, reduction='mean') +``` + +### [paddle.nn.functional.gaussian_nll_loss](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/gaussian_nll_loss_cn.html#gaussian-nll-loss) + +```python +paddle.nn.functional.gaussian_nll_loss(input, label, variance, full=False, epsilon=1e-6, reduction='mean', name=None) +``` + +两者功能一致,仅参数名不一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| --------- | ------------ | ----------------------------------------------------------------- | +| input | input | 输入 Tensor。 | +| target | label | 输入 Tensor,仅参数名不一致。 | +| var | variance | 输入 Tensor,仅参数名不一致。 | +| full | full | 是否在损失计算中包括常数项。 | +| eps | epsilon | 用于限制 variance 的值,使其不会导致除 0 的出现,仅参数名不一致。 | +| reduction | reduction | 指定应用于输出结果的计算方式。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.autograd.profiler.profile.export_chrome_trace.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.autograd.profiler.profile.export_chrome_trace.md new file mode 100644 index 00000000000..fbf520bca13 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.autograd.profiler.profile.export_chrome_trace.md @@ -0,0 +1,22 @@ +## [仅 paddle 参数更多]torch.autograd.profiler.profile.export_chrome_trace + +### [torch.autograd.profiler.profile.export_chrome_trace](https://pytorch.org/docs/stable/generated/torch.autograd.profiler.profile.export_chrome_trace.html#torch.autograd.profiler.profile.export_chrome_trace) + +```python +torch.autograd.profiler.profile.export_chrome_trace(path) +``` + +### [paddle.profiler.export_chrome_tracing](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/profiler/export_chrome_tracing_cn.html) + +```python +paddle.profiler.export_chrome_tracing(dir_name: str, worker_name: Optional[str] = None) +``` + +Paddle 相比 PyTorch 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | -------------------------------------------------- | +| path | dir_name | 性能数据导出所保存到的文件夹路径,仅参数名不一致。 | +| - | worker_name | 性能数据导出所保存到的文件名前缀。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.special.i0e.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.special.i0e.md new file mode 100644 index 00000000000..e930dc7a683 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.special.i0e.md @@ -0,0 +1,36 @@ +## [torch 参数更多]torch.special.i0e + +### [torch.special.i0e](https://pytorch.org/docs/stable/special.html#torch.special.i0e) + +```python +torch.special.i0e(input, *, out=None) +``` + +### [paddle.i0e](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/i0e_cn.html) + +```python +paddle.i0e(x, name=None) +``` + +其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | -------------------------------------------------- | +| input | x | 表示输入的 Tensor,仅参数名不一致。 | +| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 | + +### 转写示例 + +#### out:指定输出 + +```python +# Pytorch 写法 +x = torch.tensor([1, 2, 3, 4, 5], dtype=torch.float32) +torch.special.i0e(x, out=y) + +# Paddle 写法 +x = paddle.to_tensor([1, 2, 3, 4, 5], dtype="float32") +paddle.assign(paddle.i0e(x), y) +``` From 8e076371a9324f1aba1a587afe9432efcf639f9f Mon Sep 17 00:00:00 2001 From: co63oc Date: Sun, 23 Jul 2023 08:47:53 +0800 Subject: [PATCH 2/2] Fix --- ...torch.autograd.profiler.profile.export_chrome_trace.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.autograd.profiler.profile.export_chrome_trace.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.autograd.profiler.profile.export_chrome_trace.md index fbf520bca13..cb3f89c27b5 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.autograd.profiler.profile.export_chrome_trace.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.autograd.profiler.profile.export_chrome_trace.md @@ -16,7 +16,7 @@ Paddle 相比 PyTorch 支持更多其他参数,具体如下: ### 参数映射 -| PyTorch | PaddlePaddle | 备注 | -| ------- | ------------ | -------------------------------------------------- | -| path | dir_name | 性能数据导出所保存到的文件夹路径,仅参数名不一致。 | -| - | worker_name | 性能数据导出所保存到的文件名前缀。 | +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ------------------------------------------------------------------------- | +| path | dir_name | 性能数据导出所保存到的文件夹路径,仅参数名不一致。 | +| - | worker_name | 性能数据导出所保存到的文件名前缀,PyTorch 无此参数,Paddle 保持默认即可。 |