-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[API Compatibility No.6] Sink bitwise_xor and bitwise_xor_ to cpp -part #76341
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 3 commits
d74db35
80d3ad9
c7ed42b
4ed899f
f6841d0
9f92fbd
4f01bbc
6d385e6
c9e9706
0f7b938
2b1b309
e25e4da
db3b1fb
d5240bf
d3bab02
38b750c
b7bf087
a434bce
ea3d45e
68d4666
a34a8de
24bc5c1
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 |
|---|---|---|
|
|
@@ -1209,6 +1209,7 @@ def bitwise_or_(x: Tensor, y: Tensor, name: str | None = None) -> Tensor: | |
| return _C_ops.bitwise_or_(x, y) | ||
|
|
||
|
|
||
| @param_two_alias(["x", "input"], ["y", "other"]) | ||
Manfredss marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def bitwise_xor( | ||
| x: Tensor, y: Tensor, out: Tensor | None = None, name: str | None = None | ||
| ) -> Tensor: | ||
|
|
@@ -1224,9 +1225,15 @@ def bitwise_xor( | |
|
|
||
| .. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor | ||
|
|
||
|
||
| .. note:: | ||
| Alias Support: The parameter name ``input`` can be used as an alias for ``x``, and ``other`` can be used as an alias for ``y``. | ||
| For example, ``bitwise_xor(input=tensor_x, other=tensor_y, ...)`` is equivalent to ``bitwise_xor(x=tensor_x, y=tensor_y, ...)``. | ||
|
|
||
| Args: | ||
| x (Tensor): Input Tensor of ``bitwise_xor`` . It is a N-D Tensor of bool, uint8, int8, int16, int32, int64. | ||
| alias: ``input``. | ||
| y (Tensor): Input Tensor of ``bitwise_xor`` . It is a N-D Tensor of bool, uint8, int8, int16, int32, int64. | ||
| alias: ``other``. | ||
| out (Tensor|None, optional): Result of ``bitwise_xor`` . It is a N-D Tensor with the same data type of input Tensor. Default: None. | ||
| name (str|None, optional): The default value is None. Normally there is no need for | ||
| user to set this property. For more information, please refer to :ref:`api_guide_Name`. | ||
|
|
@@ -1268,6 +1275,7 @@ def __rxor__( | |
|
|
||
|
|
||
| @inplace_apis_in_dygraph_only | ||
| @ParamAliasDecorator({"x": ["input"], "y": ["other"]}) | ||
|
||
| def bitwise_xor_(x: Tensor, y: Tensor, name: str | None = None) -> Tensor: | ||
| r""" | ||
| Inplace version of ``bitwise_xor`` API, the output Tensor will be inplaced with input ``x``. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1553,6 +1553,22 @@ def non_inplace_api_processing(self, var): | |
| return paddle.bitwise_xor(var, self.y) | ||
|
|
||
|
|
||
| class TestDygraphInplacBitwiseXorAlias1(TestDygraphInplacBitwiseAnd): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. paddle.bitwise_xor测一下compat情况下的用法
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bitwise_xor_ 需要吗?好像 bitwise_xor_ 用了 compat 会有 segfault 的情况,我认为可能是 bitwise_xor_ 下沉了但是 ops.yaml 里没有 bitwise_xor_ 的定义。需要添加吗?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ops.yaml里不需要bitwise_xor_定义,会根据bitwise_xor的inplace字段,来生成bitwise_xor_ 两者本质是共享一个kernel的,只在输出out处理这里有些区别。
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
先按标准来测试,不要绕过,先提前暴露问题。 如果inplace的API下沉不了就先用装饰器吧,底层问题先暴露出来。因为这也是第1个inplace的API下沉。
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 好像是 Paddle 的 eager execution engine 执行 inplace 函数的问题,第一个参数(即被修改的参数)必须作为位置参数传递,而不是 kwarg。因为 C++ 返回逻辑会专门在位置元组 args 中查找输入张量并将其作为结果返回。如果将其作为 kwarg 传递,则 args 为空,导致 segfault。 |
||
| def inplace_api_processing(self, var): | ||
| return paddle.bitwise_xor_(var, other=self.y) | ||
|
|
||
| def non_inplace_api_processing(self, var): | ||
| return paddle.bitwise_xor(var, other=self.y) | ||
|
|
||
|
|
||
| class TestDygraphInplacBitwiseXorAlias2(TestDygraphInplacBitwiseAnd): | ||
| def inplace_api_processing(self, var): | ||
| return paddle.bitwise_xor_(input=var, other=self.y) | ||
|
|
||
| def non_inplace_api_processing(self, var): | ||
| return paddle.bitwise_xor(input=var, other=self.y) | ||
|
|
||
|
|
||
| class TestDygraphInplacBitwiseNot(TestDygraphInplacBitwiseAnd): | ||
| def inplace_api_processing(self, var): | ||
| return paddle.bitwise_not_(var) | ||
|
|
||
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.
这个是bitwise_xor还是bitwise_xor_?
前者是非inplace的,后者是inplace的
Uh oh!
There was an error while loading. Please reload this page.
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.
修复列表里写的是 bitwise_xor_,所以这里写的 bitwise_xor_。这个 API 只能通过装饰器来修改
但 bitwise_xor 是能够 cpp 下沉的,所以有些疑惑 @zhwesky2010