From 3b1205053fb73a4412834878d8fcdc9d8057e114 Mon Sep 17 00:00:00 2001 From: ooo oo <106524776+ooooo-create@users.noreply.github.com> Date: Wed, 28 May 2025 05:56:17 +0000 Subject: [PATCH 1/3] fix --- tester/paddle_to_torch/rules.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tester/paddle_to_torch/rules.py b/tester/paddle_to_torch/rules.py index 8980c46d..63809a9d 100644 --- a/tester/paddle_to_torch/rules.py +++ b/tester/paddle_to_torch/rules.py @@ -3797,6 +3797,11 @@ def apply(self, paddle_api: str) -> ConvertResult: result = x.abs().amin() else: result = {self.torch_api}(**_kwargs) +elif len(x.shape)==2 and axis is None: + _kwargs["input"] = x.flatten() + result = {self.torch_api}(**_kwargs) + if keepdim: + result = result.unsqueeze(0) else: result = {self.torch_api}(**_kwargs) """ From f956bc873d819540b27c40cd5ae3d5203c822444 Mon Sep 17 00:00:00 2001 From: ooo oo <106524776+ooooo-create@users.noreply.github.com> Date: Wed, 28 May 2025 06:10:04 +0000 Subject: [PATCH 2/3] fix --- tester/paddle_to_torch/rules.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tester/paddle_to_torch/rules.py b/tester/paddle_to_torch/rules.py index 63809a9d..e8971072 100644 --- a/tester/paddle_to_torch/rules.py +++ b/tester/paddle_to_torch/rules.py @@ -3784,7 +3784,7 @@ def apply(self, paddle_api: str) -> ConvertResult: result = (x!= 0).sum(dim=axis, keepdim=True).to(x.dtype) else: result = (x!= 0).sum(dim=axis).to(x.dtype) -elif len(x.shape)>2 and axis is None: +elif len(x.shape)>=2 and axis is None: if p==math.inf: if keepdim: result = x.abs().amax().reshape([1] * x.ndim) @@ -3796,12 +3796,10 @@ def apply(self, paddle_api: str) -> ConvertResult: else: result = x.abs().amin() else: + _kwargs["input"] = x.flatten() result = {self.torch_api}(**_kwargs) -elif len(x.shape)==2 and axis is None: - _kwargs["input"] = x.flatten() - result = {self.torch_api}(**_kwargs) - if keepdim: - result = result.unsqueeze(0) + if keepdim: + result = result.reshape([1] * x.ndim) else: result = {self.torch_api}(**_kwargs) """ From 49e7bce9c41a319d1b87676665c5fc62fb68fe04 Mon Sep 17 00:00:00 2001 From: ooo oo <106524776+ooooo-create@users.noreply.github.com> Date: Wed, 28 May 2025 09:40:51 +0000 Subject: [PATCH 3/3] refine --- tester/paddle_to_torch/rules.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tester/paddle_to_torch/rules.py b/tester/paddle_to_torch/rules.py index e8971072..023dd028 100644 --- a/tester/paddle_to_torch/rules.py +++ b/tester/paddle_to_torch/rules.py @@ -3797,6 +3797,8 @@ def apply(self, paddle_api: str) -> ConvertResult: result = x.abs().amin() else: _kwargs["input"] = x.flatten() + if p == "fro": + _kwargs["ord"] = 2 result = {self.torch_api}(**_kwargs) if keepdim: result = result.reshape([1] * x.ndim)