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

Enforce adding documentation for builtin numpy operators #16575

Merged
merged 2 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/operator/numpy/np_elemwise_broadcast_op.cu
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,5 @@ NNVM_REGISTER_OP(_backward_npi_ldexp_scalar)
NNVM_REGISTER_OP(_backward_npi_rldexp_scalar)
.set_attr<FCompute>("FCompute<gpu>", BinaryScalarOp::Backward<gpu, mshadow_op::rldexp_grad>);

NNVM_REGISTER_OP(_np_bitwise_xor)
.set_attr<FCompute>("FCompute<gpu>", BinaryBroadcastCompute<gpu, mshadow_op::bitwise_xor>);

} // namespace op
} // namespace mxnet
12 changes: 9 additions & 3 deletions tests/python/unittest/test_numpy_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from mxnet.test_utils import verify_generator, gen_buckets_probs_with_ppf
from mxnet.numpy_op_signature import _get_builtin_op
from mxnet.test_utils import is_op_runnable, has_tvm_ops
from mxnet.operator import get_all_registered_operators


@with_seed()
Expand Down Expand Up @@ -3164,10 +3165,15 @@ def check_output_n_grad(data_shape, idx_shape, axis, mode):
def test_np_builtin_op_signature():
import inspect
from mxnet import _numpy_op_doc
for op_name in dir(_numpy_op_doc):
builtin_np_op_names = [name for name in get_all_registered_operators() if name.startswith('_np_')]
for op_name in builtin_np_op_names:
_op_from_doc = getattr(_numpy_op_doc, op_name, None)
assert _op_from_doc is not None, "Failed to find documentation for operator {}. " \
"Please add the documentation in _numpy_op_doc.py for this operator."\
.format(op_name)
op = _get_builtin_op(op_name)
if op is not None:
assert str(op.__signature__) == str(inspect.signature(getattr(_numpy_op_doc, op_name)))
assert op is not None
assert str(op.__signature__) == str(inspect.signature(_op_from_doc))


@with_seed()
Expand Down