Skip to content

Conversation

@zhengshengning
Copy link
Contributor

@zhengshengning zhengshengning commented Aug 12, 2025

PR Category

Operator Mechanism

PR Types

Improvements

Description

paddle.diff
paddle.median
paddle.multinomial
paddle.Tensor.exponential_

API Name Param Alias
paddle.diff x,axis input, dim
paddle.median x,axis input,dim
paddle.multinomial x input
paddle.Tensor.exponential_leave lam lambd

【添加一个可以设置默认参数的类】
使用场景:当torch没有某个参数时,需要设置一个paddle对应的参数才能与torch原本的含义对齐,新增的default_params字典为torch设置的对应参数。

class SetDefaultParaAliasDecorator(DecoratorBase):
    def __init__(self, alias_mapping: dict[str, Iterable[str]], default_params: dict[str, Any],) -> None:
        ......
        self.default_params = default_params
        warnings.simplefilter("always", category=Warning)

    def process(self, args: tuple[Any, ...], kwargs: dict[str, Any]) -> tuple[tuple[Any, ...], dict[str, Any]]:
        is_torch_call = False
        ........
        if is_torch_call:
            warnings.warn( "Set default parameters " + str(self.default_params), category=Warning,)
            for key, value in self.default_params.items():
                if key not in kwargs:
                    kwargs[key] = value
        return args, kwargs

使用:

@SetDefaultParaAliasDecorator(
    {"x": ["input"], "axis": ["dim"]}, {"mode": 'min'}
)
void func(...){
}

Other
增加了单测

pcard-67164

@paddle-bot
Copy link

paddle-bot bot commented Aug 12, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 92.30769% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@c466f94). Learn more about missing BASE report.

Files with missing lines Patch % Lines
python/paddle/utils/decorator_utils.py 90.32% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #74568   +/-   ##
==========================================
  Coverage           ?   92.30%           
==========================================
  Files              ?        4           
  Lines              ?       39           
  Branches           ?        0           
==========================================
  Hits               ?       36           
  Misses             ?        3           
  Partials           ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhengshengning
Copy link
Contributor Author

/re-run all-failed

@zhangbo9674 zhangbo9674 merged commit c2f8e7c into PaddlePaddle:develop Aug 14, 2025
72 of 73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants