-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[API Compatibility No.361] Param alias for lerp using decorator -part #77170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 4 commits
63db1e0
e785546
af9a919
6a4886a
b3058ed
2322c31
af9b8a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4821,8 +4821,14 @@ def logit_( | |
| return _C_ops.logit_(x, eps) | ||
|
|
||
|
|
||
| @param_two_alias(["x", "input"], ["y", "end"]) | ||
| def lerp( | ||
| x: Tensor, y: Tensor, weight: float | Tensor, name: str | None = None | ||
| x: Tensor, | ||
| y: Tensor, | ||
| weight: float | Tensor, | ||
| name: str | None = None, | ||
| *, | ||
| out: Tensor | None = None, | ||
| ) -> Tensor: | ||
| r""" | ||
| Does a linear interpolation between x and y based on weight. | ||
|
|
@@ -4834,9 +4840,12 @@ def lerp( | |
|
|
||
| Args: | ||
| x (Tensor): An N-D Tensor with starting points, the data type is bfloat16, float16, float32, float64. | ||
| Alias: ``input`` . | ||
| y (Tensor): An N-D Tensor with ending points, the data type is bfloat16, float16, float32, float64. | ||
| Alias: ``end`` . | ||
| weight (float|Tensor): The weight for the interpolation formula. When weight is Tensor, the data type is bfloat16, float16, float32, float64. | ||
| name (str|None, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`. | ||
| out (Tensor|None, optional): The output Tensor. If provided, the result will be stored in `out`. Default is None. | ||
|
|
||
| Returns: | ||
| out (Tensor): An N-D Tensor, the shape and data type is the same with input. | ||
|
|
@@ -4862,7 +4871,8 @@ def lerp( | |
| weight = paddle.full(shape=[], fill_value=weight, dtype=x.dtype) | ||
|
|
||
| if in_dynamic_or_pir_mode(): | ||
| return _C_ops.lerp(x, y, weight) | ||
| if out is None: | ||
| return _C_ops.lerp(x, y, weight, out=out) | ||
|
||
| else: | ||
| check_variable_and_dtype( | ||
| x, 'x', ['uint16', 'float16', 'float32', 'float64'], 'lerp' | ||
|
|
@@ -4879,11 +4889,13 @@ def lerp( | |
|
|
||
| helper = LayerHelper('lerp', **locals()) | ||
| inputs = {'X': x, 'Y': y, 'Weight': weight} | ||
| out = helper.create_variable_for_type_inference(dtype=x.dtype) | ||
| if out is None: | ||
| out = helper.create_variable_for_type_inference(dtype=x.dtype) | ||
| helper.append_op(type='lerp', inputs=inputs, outputs={'Out': out}) | ||
| return out | ||
|
|
||
|
|
||
| @param_two_alias(["x", "input"], ["y", "end"]) | ||
| @inplace_apis_in_dygraph_only | ||
| def lerp_( | ||
| x: Tensor, y: Tensor, weight: float | Tensor, name: str | None = None | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果out非None,这里没有处理。这里其实不需要处理,因为_C_ops里面自己会处理是否为None的情况