Add bitwise elementwise specifications #54
Merged
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.
This PR
&
,|
,^
,~
,>>
, and<<
.Notes
The specifications follow the same form as other elementwise functions.
Functional bitwise APIs are, while not ubiquitous, commonly implemented across array libraries. The principle impetus for their inclusion is to have functional equivalents of operators (as discussed and endorsed during a prior consortium meeting).
This PR induces a slightly different naming convention. NumPy (and its followers) splits its namespace into non-prefixed and prefixed APIs (e.g.,
right_shift
vsbitwise_and
). TensorFlow puts everything under atf.bitwise
namespace, while also using abitwise_
prefix for certain APIs.This PR chooses to simply put all bitwise operations under a
bitwise_
prefix. This matches, and is consistent with, the current convention of using alogical_
prefix for logical operations.This PR currently requires that
x2
for bothright_shift
andleft_shift
have nonnegative elements. NumPy's docs forleft_shift
state that this is required; although, from the interpreter, no error is thrown if a negativex2
is provided. TensorFlow states that negativex2
results in implementation-dependent behavior.This PR takes the stance that negative
x2
for eitherleft_shift
andright_shift
is probably a mistake and should not be permitted. Hence, the included requirements thatx2
be greater than or equal to0
.