Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Numpy] Numpy compatible bitwise_and operator #16009

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

zoeygxy
Copy link
Contributor

@zoeygxy zoeygxy commented Aug 26, 2019

Description

Numpy element-wise operator bitwise_and added.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Code is well-documented
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Added a new InferShape method ElemwiseIntType that can be used to constrain dtypes to ints.
  • Added numpy element-wise operator: bitwise_and

Comments

  • Since boolean array is not supported yet, this operator now only supports calculation between integer scalars / ndarrays. May need some change to support boolean arrays in the future. @reminisce

@zoeygxy zoeygxy requested a review from szha as a code owner August 26, 2019 08:59
@zoeygxy
Copy link
Contributor Author

zoeygxy commented Aug 26, 2019

@haojin2

@anirudhacharya
Copy link
Member

@mxnet-label-bot add [pr-awaiting-review]

@marcoabreu marcoabreu added the pr-awaiting-review PR is waiting for code review label Aug 26, 2019
@zoeygxy zoeygxy mentioned this pull request Aug 26, 2019
5 tasks
@haojin2 haojin2 added the Numpy label Aug 27, 2019
@haojin2 haojin2 self-assigned this Aug 27, 2019
@haojin2 haojin2 requested review from haojin2 and reminisce and removed request for szha August 27, 2019 03:03
Copy link
Contributor

@haojin2 haojin2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

test_bitwise_and.hybridize()

x1 = rand_ndarray(x1_shape, dtype=_np.dtype(int)).as_np_ndarray()
x2 = rand_ndarray(x2_shape, dtype=_np.dtype(int)).as_np_ndarray()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we test for all the supported dtypes, I think we support uint8, int8, int32, int64.

// Special case of ElemwiseType. Constrains dtype to integer types
template<index_t n_in, index_t n_out>
inline bool ElemwiseIntType(const nnvm::NodeAttrs& attrs,
std::vector<int> *in_attrs,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alignment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Numpy pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants