From a8adc8ad69be2d62c4cb1c44fe792f1395ba1c8d Mon Sep 17 00:00:00 2001 From: feixi139 <66367509+feixi139@users.noreply.github.com> Date: Thu, 27 Aug 2026 15:28:09 +0800 Subject: [PATCH 1/2] fix rules for paddle.nn.clip._squared_l2_norm --- tester/paddle_to_torch/mapping.json | 3 +++ tester/paddle_to_torch/rules.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tester/paddle_to_torch/mapping.json b/tester/paddle_to_torch/mapping.json index e070b224..450639ba 100644 --- a/tester/paddle_to_torch/mapping.json +++ b/tester/paddle_to_torch/mapping.json @@ -5116,6 +5116,9 @@ "paddle._C_ops.squared_l2_norm": { "Rule": "CopsSquaredL2NormRule" }, + "paddle.nn.clip._squared_l2_norm": { + "Rule": "CopsSquaredL2NormRule" + }, "paddle._C_ops.subtract_": { "Rule": "CopsSubtractRule" }, diff --git a/tester/paddle_to_torch/rules.py b/tester/paddle_to_torch/rules.py index 62a70ae1..1c5d151b 100644 --- a/tester/paddle_to_torch/rules.py +++ b/tester/paddle_to_torch/rules.py @@ -9185,7 +9185,11 @@ def apply(self, paddle_api: str) -> ConvertResult: class CopsSquaredL2NormRule(BaseRule): - PADDLE_APIS = ("paddle._C_ops.squared_l2_norm",) + # Python 包装入口在动态图/PIR 下直接委托同一 C++ kernel。 + PADDLE_APIS = ( + "paddle._C_ops.squared_l2_norm", + "paddle.nn.clip._squared_l2_norm", + ) """paddle._C_ops.squared_l2_norm(x) → (x * x).sum() with shape [1] to match Paddle output""" From ff2f87549261968353c8e2d0d381cf675de4ae47 Mon Sep 17 00:00:00 2001 From: feixi139 <66367509+feixi139@users.noreply.github.com> Date: Thu, 27 Aug 2026 16:49:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=B8=B8=E7=94=A8=20Padd?= =?UTF-8?q?le=20API=20=E7=9A=84=20Torch=20=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tester/paddle_to_torch/mapping.json | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tester/paddle_to_torch/mapping.json b/tester/paddle_to_torch/mapping.json index 450639ba..f9aef13b 100644 --- a/tester/paddle_to_torch/mapping.json +++ b/tester/paddle_to_torch/mapping.json @@ -378,6 +378,16 @@ "y": "other" } }, + "paddle.baddbmm": { + "torch_api": "torch.baddbmm", + "paddle_torch_args_map": { + "input": "input", + "x": "batch1", + "y": "batch2", + "beta": "beta", + "alpha": "alpha" + } + }, "paddle.bmm": { "Rule": "BmmRule", "torch_api": "torch.bmm", @@ -433,6 +443,13 @@ "paddle.Tensor.cast": { "Rule": "CastRule" }, + "paddle.cat": { + "torch_api": "torch.cat", + "paddle_torch_args_map": { + "x": "tensors", + "axis": "dim" + } + }, "paddle.cdist": { "torch_api": "torch.cdist", "paddle_torch_args_map": { @@ -495,6 +512,14 @@ "max": "max" } }, + "paddle.clamp": { + "torch_api": "torch.clamp", + "paddle_torch_args_map": { + "x": "input", + "min": "min", + "max": "max" + } + }, "paddle.clone": { "torch_api": "torch.clone", "paddle_torch_args_map": { @@ -3667,6 +3692,14 @@ "paddle.nn.functional.zeropad2d": { "Rule": "Zeropad2dRule" }, + "paddle.nn.init.normal_": { + "torch_api": "torch.nn.init.normal_", + "paddle_torch_args_map": { + "tensor": "tensor", + "mean": "mean", + "std": "std" + } + }, "paddle.nn.init.trunc_normal_": { "Rule": "TruncNormalRule", "torch_api": "torch.nn.init.trunc_normal_", @@ -4251,6 +4284,16 @@ "dtype": "dtype" } }, + "paddle.randn": { + "torch_api": "torch.randn", + "set_defaults": { + "dtype": "None" + }, + "paddle_torch_args_map": { + "shape": "size", + "dtype": "dtype" + } + }, "paddle.stanh": { "Rule": "StanhRule", "torch_api": "torch.tanh",