-
Notifications
You must be signed in to change notification settings - Fork 764
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
【Hackathon 5th No.34】为 Paddle 新增 bitwise_right_shift / bitwise_right_shift_ / bitwise_left_shift / bitwise_left_shift_ API 中文文档 #6399
Merged
Merged
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a63a036
add householder_product_cn doc
cocoshe 7cba614
doc style
cocoshe 14e33d4
add bitwise_shift zh doc
cocoshe 282a33e
Update Overview_cn.rst
cocoshe 92a7cef
Update Overview_cn.rst
cocoshe 05044c8
Delete docs/api/paddle/linalg/householder_product_cn.rst
cocoshe 559b114
add notice for overflow
cocoshe 6a0c91e
Update docs/api/paddle/bitwise_left_shift_cn.rst
cocoshe 1f635a3
fix doc example
cocoshe ff8e495
Merge branch 'bitwise_shift_zh' of https://github.com/cocoshe/docs in…
cocoshe 7122f57
add inplace doc
cocoshe c8d4907
Update docs/api/paddle/bitwise_left_shift_cn.rst
cocoshe bf8f202
add inplace
cocoshe adcfc81
docstyle
cocoshe 4fb1b27
Merge branch 'develop' into bitwise_shift_zh
cocoshe 4656a33
Update docs/api/paddle/bitwise_left_shift__cn.rst
cocoshe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.. _cn_api_paddle_bitwise_left_shift_: | ||
|
||
bitwise_left_shift\_ | ||
------------------------------- | ||
|
||
.. py:function:: paddle.bitwise_right_shift_(x, y, is_arithmetic=True, out=None, name=None) | ||
cocoshe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Inplace 版本的 :ref:`cn_api_paddle_bitwise_left_shift` API,对输入 `x` 采用 Inplace 策略。 | ||
|
||
更多关于 inplace 操作的介绍请参考 `3.1.3 原位(Inplace)操作和非原位操作的区别`_ 了解详情。 | ||
|
||
.. _3.1.3 原位(Inplace)操作和非原位操作的区别: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/beginner/tensor_cn.html#id3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
.. _cn_api_paddle_bitwise_left_shift: | ||
|
||
bitwise_left_shift | ||
------------------------------- | ||
|
||
.. py:function:: paddle.bitwise_left_shift(x, y, is_arithmetic=True, out=None, name=None) | ||
|
||
对 Tensor ``x`` 和 ``y`` 逐元素进行 ``按位算术(或逻辑)左移`` 运算。 | ||
|
||
+ 关于**有符号数的符号位**在不同情景下的行为: | ||
cocoshe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
1. 算术左移时,符号位同其他位一样,一起左移,右边补0; | ||
2. 逻辑左移时,符号位同其他位一样,一起左移,右边补0; | ||
3. 算术右移时,符号位同其他位一样,一起右移,左边补符号位; | ||
4. 逻辑右移时,符号位同其他位一样,一起右移,左边补0; | ||
|
||
.. note:: | ||
当有符号数左移发生溢出时,其值不可控,可能会在左移时突然变号,这是因为在左移时,有符号数的符号位同样进行左移,会导致符号位右侧的值不断成为符号位,例如 | ||
|
||
example1: | ||
|
||
.. code-block:: text | ||
|
||
int8_t x = -45; // 补码为 1101,0011 表示-45 | ||
|
||
int8_t y = x << 2; //补码为 0100,1100 表示76 | ||
|
||
int8_t z = x << 3; //补码为 1001,1000 表示-104 | ||
|
||
example2: | ||
|
||
.. code-block:: text | ||
|
||
int8_t x = -86; // 补码为 1010,1010 表示-86 | ||
|
||
int8_t y = x << 1; //补码为 0101,0100 表示84 | ||
|
||
int8_t z = x << 2; //补码为 1010,1000 表示-88 | ||
|
||
以上为溢出导致的符号突变。 | ||
|
||
.. math:: | ||
Out = X \ll Y | ||
|
||
.. note:: | ||
``paddle.bitwise_left_shift`` 遵守 broadcasting,如您想了解更多,请参见 `Tensor 介绍`_ . | ||
|
||
.. _Tensor 介绍: ../../guides/beginner/tensor_cn.html#id7 | ||
参数 | ||
:::::::::::: | ||
|
||
- **x** (Tensor)- 输入的 N-D `Tensor`,数据类型为:uint8,int8,int16,int32,int64。 | ||
- **y** (Tensor)- 输入的 N-D `Tensor`,数据类型为:uint8,int8,int16,int32,int64。 | ||
- **is_arithmetic** (bool) - 用于表明是否执行算术位移,True 表示算术位移,False 表示逻辑位移。默认值为 True,表示算术位移。 | ||
- **out** (Tensor,可选)- 输出的结果 `Tensor`,是与输入数据类型相同的 N-D `Tensor`。默认值为 None,此时将创建新的 Tensor 来保存输出结果。 | ||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 | ||
|
||
|
||
返回 | ||
:::::::::::: | ||
``按位算术(逻辑)左移`` 运算后的结果 ``Tensor``,数据类型与 ``x`` 相同。 | ||
|
||
代码示例1 | ||
:::::::::::: | ||
|
||
算术左移 | ||
|
||
COPY-FROM: paddle.bitwise_left_shift:bitwise_left_shift_example1 | ||
|
||
代码示例2 | ||
:::::::::::: | ||
|
||
逻辑左移 | ||
|
||
COPY-FROM: paddle.bitwise_left_shift:bitwise_left_shift_example2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.. _cn_api_paddle_bitwise_right_shift_: | ||
|
||
bitwise_right_shift\_ | ||
------------------------------- | ||
|
||
.. py:function:: paddle.bitwise_right_shift_(x, y, is_arithmetic=True, out=None, name=None) | ||
|
||
Inplace 版本的 :ref:`cn_api_paddle_bitwise_right_shift` API,对输入 `x` 采用 Inplace 策略。 | ||
|
||
更多关于 inplace 操作的介绍请参考 `3.1.3 原位(Inplace)操作和非原位操作的区别`_ 了解详情。 | ||
|
||
.. _3.1.3 原位(Inplace)操作和非原位操作的区别: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/beginner/tensor_cn.html#id3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.. _cn_api_paddle_bitwise_right_shift: | ||
|
||
bitwise_right_shift | ||
------------------------------- | ||
|
||
.. py:function:: paddle.bitwise_right_shift(x, y, is_arithmetic=True, out=None, name=None) | ||
|
||
对 Tensor ``x`` 和 ``y`` 逐元素进行 ``按位算术(或逻辑)右移`` 运算。 | ||
|
||
.. math:: | ||
Out = X \gg Y | ||
|
||
.. note:: | ||
``paddle.bitwise_right_shift`` 遵守 broadcasting,如您想了解更多,请参见 `Tensor 介绍`_ . | ||
|
||
.. _Tensor 介绍: ../../guides/beginner/tensor_cn.html#id7 | ||
参数 | ||
:::::::::::: | ||
|
||
- **x** (Tensor)- 输入的 N-D `Tensor`,数据类型为:uint8,int8,int16,int32,int64。 | ||
- **y** (Tensor)- 输入的 N-D `Tensor`,数据类型为:uint8,int8,int16,int32,int64。 | ||
- **is_arithmetic** (bool) - 用于表明是否执行算术位移,True 表示算术位移,False 表示逻辑位移。默认值为 True,表示算术位移。 | ||
- **out** (Tensor,可选)- 输出的结果 `Tensor`,是与输入数据类型相同的 N-D `Tensor`。默认值为 None,此时将创建新的 Tensor 来保存输出结果。 | ||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 | ||
|
||
返回 | ||
:::::::::::: | ||
``按位算术(逻辑)右移`` 运算后的结果 ``Tensor``,数据类型与 ``x`` 相同。 | ||
|
||
代码示例1 | ||
:::::::::::: | ||
|
||
算术右移 | ||
|
||
COPY-FROM: paddle.bitwise_right_shift:bitwise_right_shift_example1 | ||
|
||
代码示例2 | ||
:::::::::::: | ||
|
||
逻辑右移 | ||
|
||
COPY-FROM: paddle.bitwise_right_shift:bitwise_right_shift_example2 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
同理,overview 少了 2 个inplace API