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

[MXNET-392] Support for a bunch of unary functions for csr matrices #11559

Merged
merged 24 commits into from
Jul 6, 2018

Conversation

haojin2
Copy link
Contributor

@haojin2 haojin2 commented Jul 4, 2018

Description

As title

Checklist

Essentials

  • 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)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http:https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Support for relu, sign, round, ceil, floor, trunc, fix, sqrt, cbrt, log1p, expm1, sin, tan, arcsin, arctan, sinh, arcsinh, tanh, arctanh, degrees, radians
  • Corresponding unit tests

Comments

@haojin2
Copy link
Contributor Author

haojin2 commented Jul 4, 2018

@eric-haibin-lin

Copy link
Member

@eric-haibin-lin eric-haibin-lin left a comment

Choose a reason for hiding this comment

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

Good job. a few comments:

@@ -70,7 +70,7 @@ static bool IdentityAttrLikeRhsStorageType(const nnvm::NodeAttrs& attrs,
}

// relu
MXNET_OPERATOR_REGISTER_UNARY(relu)
MXNET_OPERATOR_REGISTER_UNARY_WITH_RSP_CSR(relu, cpu, mshadow_op::relu)
Copy link
Member

Choose a reason for hiding this comment

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

We probably want to move MXNET_ADD_SPARSE_OP_ALIAS inside MXNET_OPERATOR_REGISTER_UNARY_WITH_RSP_CSR. Do you mind changing that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually none of MXNET_OPERATOR_REGISTER_UNARY_WITH_RSP_CSR/MXNET_OPERATOR_REGISTER_UNARY_WITH_RSP/MXNET_OPERATOR_REGISTER_UNARY_WITH_SPARSE_DR has MXNET_ADD_SPARSE_OP_ALIAS in them, do you want to add that to all of them?

Copy link
Member

Choose a reason for hiding this comment

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

Add for MXNET_OPERATOR_REGISTER_UNARY_WITH_RSP_CSR and MXNET_OPERATOR_REGISTER_UNARY_WITH_RSP. Lets skip the ones with SPARSE_DR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -81,11 +81,9 @@ The storage type of ``relu`` output depends upon the input storage type:

- relu(default) = default
- relu(row_sparse) = row_sparse
- relu(csr) = csr
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -520,7 +583,7 @@ We summarize the interface for each class in the following sections.
```eval_rst

.. autoclass:: mxnet.ndarray.sparse.CSRNDArray
:members: shape, context, dtype, stype, data, indices, indptr, copy, copyto, as_in_context, asscipy, asnumpy, asscalar, astype, tostype, slice, wait_to_read, zeros_like, __neg__, sum, mean, norm, square, __getitem__, __setitem__, check_format
:members: shape, context, dtype, stype, data, indices, indptr, copy, copyto, as_in_context, asscipy, asnumpy, asscalar, astype, tostype, slice, wait_to_read, zeros_like, round, rint, fix, floor, ceil, trunc, sin, tan, arcsin, arctan, degrees, radians, sinh, tanh, arcsinh, arctanh, expm1, log1p, sqrt, square, __neg__, sum, mean, norm, square, __getitem__, __setitem__, check_format, clip, sign

.. autoclass:: mxnet.ndarray.sparse.RowSparseNDArray
:members: shape, context, dtype, stype, data, indices, copy, copyto, as_in_context, asnumpy, asscalar, astype, tostype, wait_to_read, zeros_like, round, rint, fix, floor, ceil, trunc, sin, tan, arcsin, arctan, degrees, radians, sinh, tanh, arcsinh, arctanh, expm1, log1p, sqrt, square, __negative__, norm, __getitem__, __setitem__, check_format, retain, clip, sign
Copy link
Member

Choose a reason for hiding this comment

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

Also add abs for RowSparse: members?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh you mean this one, will do soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@eric-haibin-lin eric-haibin-lin left a comment

Choose a reason for hiding this comment

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

good to merge once the last comment is addressed

@eric-haibin-lin eric-haibin-lin merged commit 52dcb19 into apache:master Jul 6, 2018
@haojin2 haojin2 deleted the csr_unary branch July 19, 2018 20:11
XinYao1994 pushed a commit to XinYao1994/incubator-mxnet that referenced this pull request Aug 29, 2018
…pache#11559)

* support for relu(csr) = csr

* add support for sign(csr) = csr

* add support for round

* add support for ceil(csr)=csr

* add support for floor(csr)=csr

* add support for trunc(csr)=csr

* add support for fix(csr)=csr

* add support for sqrt(csr)=csr

* add support for cbrt(csr)=csr

* add support for log1p(csr)=csr

* add support for expm1(csr)=csr

* add support for sin(csr)=csr

* add support for tan(csr)=csr

* add support for arcsin(csr)=csr

* add support for arctan(csr)=csr

* add support for degrees(csr)=csr

* add support for radians(csr)=csr

* add support for sinh(csr)=csr

* add support for tanh(csr)=csr

* add support for arcsinh(csr)=csr

* add support for arctanh(csr)=csr

* restore original check_sparse_function func

* add test for fluent and doc

* address code review
@haojin2 haojin2 added the Sparse label Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants