Skip to content

[API Compatibility No.10] Add parameter alias support for floor_divide_ -part#77556

Open
CAICAIIs wants to merge 2 commits intoPaddlePaddle:developfrom
CAICAIIs:develop
Open

[API Compatibility No.10] Add parameter alias support for floor_divide_ -part#77556
CAICAIIs wants to merge 2 commits intoPaddlePaddle:developfrom
CAICAIIs:develop

Conversation

@CAICAIIs
Copy link

Background

Task #76301 No.10 aims to align torch.Tensor.floor_divide_ with paddle.Tensor.floor_divide_. The key requirement is to support PyTorch-style parameter names (other instead of y) to ensure smooth migration for PyTorch users.

Implementation

  1. Added @param_two_alias decorator to floor_divide_ function to map:
    • input → x (Paddle API parameter name)
    • other → y (PyTorch API parameter name)
  2. Added comprehensive tests to verify parameter alias support:
    • test_floor_divide_inplace_with_y_parameter: Tests using y parameter (Paddle style)
    • test_floor_divide_inplace_with_other_parameter: Tests using other parameter (PyTorch style)
    • test_floor_divide_inplace_with_both_parameters_error: Tests that using both y and other raises TypeError

Example Usage

After this PR, both PyTorch and Paddle styles work:

import paddle
x = paddle.to_tensor([6, 12, 18])
y = paddle.to_tensor([2, 3, 6])
# PyTorch style (now supported)
x.floor_divide_(other=y)
# Paddle style (still works)
x.floor_divide_(y)

Changes

  • python/paddle/tensor/math.py: Added @param_two_alias decorator to floor_divide_ function
  • test/legacy_test/test_inplace.py: Added three test methods for parameter alias support

Fixes

PR Category

User Experience

PR Types

New features

Description

This PR adds PyTorch parameter alias support for paddle.Tensor.floor_divide_ API.

…e_ -part

Add parameter alias support for paddle.Tensor.floor_divide_:
- Add @param_two_alias decorator to support 'input' as alias for 'x' and 'other' as alias for 'y'
- Add tests for parameter alias support including:
  - test_floor_divide_inplace_with_y_parameter: Test using 'y' parameter
  - test_floor_divide_inplace_with_other_parameter: Test using 'other' parameter (alias)
  - test_floor_divide_inplace_with_both_parameters_error: Test that using both 'y' and 'other' raises TypeError

## Changes
- python/paddle/tensor/math.py: Added @param_two_alias decorator to floor_divide_ function
- test/legacy_test/test_inplace.py: Added three test methods for parameter alias support

## Fixes
- Fixes PaddlePaddle#76301 task 10
@paddle-bot
Copy link

paddle-bot bot commented Jan 28, 2026

你的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.

@CLAassistant
Copy link

CLAassistant commented Jan 28, 2026

CLA assistant check
All committers have signed the CLA.

@paddle-bot paddle-bot bot added the contributor External developers label Jan 28, 2026
@CAICAIIs
Copy link
Author

PaConvert: PaddlePaddle/PaConvert#818

@zhwesky2010
Copy link
Contributor

floor_divide_ 采用C++下沉方式,但是下沉机制还有点问题。预计年后才能开展开发。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API Compatibility contributor External developers HappyOpenSource 快乐开源活动issue与PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【启航计划】PaddlePaddle API兼容性增强

4 participants

Comments