You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/02/12 05:21:53 UTC

[GitHub] [incubator-mxnet] sjtuWangDing opened a new pull request #17573: [Numpy] Add cross product op

sjtuWangDing opened a new pull request #17573: [Numpy] Add cross product op
URL: https://github.com/apache/incubator-mxnet/pull/17573
 
 
   ## Description ##
   Add cross product op.
   
   ## Checklist ##
   ### Essentials ###
   Please feel free to remove inapplicable items for your PR.
   - [ ] The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant [JIRA issue](https://issues.apache.org/jira/projects/MXNET/issues) created (except PRs with tiny changes)
   - [ ] 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 https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
   - [ ] To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [ ] Feature1, tests, (and when applicable, API doc)
   - [ ] Feature2, tests, (and when applicable, API doc)
   
   ## Comments ##
   - If this change is a backward incompatible change, why must this change be made.
   - Interesting edge cases to note here
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #17573: [Numpy] Add cross product op

Posted by GitBox <gi...@apache.org>.
haojin2 commented on a change in pull request #17573: [Numpy] Add cross product op
URL: https://github.com/apache/incubator-mxnet/pull/17573#discussion_r378652870
 
 

 ##########
 File path: python/mxnet/symbol/numpy/_symbol.py
 ##########
 @@ -6160,4 +6160,56 @@ def bincount(x, weights=None, minlength=0):
     return _npi.bincount(x, weights=weights, minlength=minlength, has_weights=True)
 
 
+@set_module('mxnet.symbol.numpy')
+def cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None, **kwargs): # pylint: disable=too-many-arguments
+    """
+    Return the cross product of two (arrays of) vectors.
+
+    The cross product of `a` and `b` in :math:`R^3` is a vector perpendicular
+    to both `a` and `b`.  If `a` and `b` are arrays of vectors, the vectors
+    are defined by the last axis of `a` and `b` by default, and these axes
+    can have dimensions 2 or 3.  Where the dimension of either `a` or `b` is
+    2, the third component of the input vector is assumed to be zero and the
+    cross product calculated accordingly.  In cases where both input vectors
+    have dimension 2, the z-component of the cross product is returned.
+
+    Parameters
+    ----------
+    a : ndarray
+        Components of the first vector(s).
+    b : ndarray
 
 Review comment:
   `b : _Symbol`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #17573: [Numpy] Add cross product op

Posted by GitBox <gi...@apache.org>.
haojin2 commented on a change in pull request #17573: [Numpy] Add cross product op
URL: https://github.com/apache/incubator-mxnet/pull/17573#discussion_r378652916
 
 

 ##########
 File path: python/mxnet/symbol/numpy/_symbol.py
 ##########
 @@ -6160,4 +6160,56 @@ def bincount(x, weights=None, minlength=0):
     return _npi.bincount(x, weights=weights, minlength=minlength, has_weights=True)
 
 
+@set_module('mxnet.symbol.numpy')
+def cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None, **kwargs): # pylint: disable=too-many-arguments
+    """
+    Return the cross product of two (arrays of) vectors.
+
+    The cross product of `a` and `b` in :math:`R^3` is a vector perpendicular
+    to both `a` and `b`.  If `a` and `b` are arrays of vectors, the vectors
+    are defined by the last axis of `a` and `b` by default, and these axes
+    can have dimensions 2 or 3.  Where the dimension of either `a` or `b` is
+    2, the third component of the input vector is assumed to be zero and the
+    cross product calculated accordingly.  In cases where both input vectors
+    have dimension 2, the z-component of the cross product is returned.
+
+    Parameters
+    ----------
+    a : ndarray
+        Components of the first vector(s).
+    b : ndarray
+        Components of the second vector(s).
+    axisa : int, optional
+        Axis of `a` that defines the vector(s).  By default, the last axis.
+    axisb : int, optional
+        Axis of `b` that defines the vector(s).  By default, the last axis.
+    axisc : int, optional
+        Axis of `c` containing the cross product vector(s).  Ignored if
+        both input vectors have dimension 2, as the return is scalar.
+        By default, the last axis.
+    axis : int, optional
+        If defined, the axis of `a`, `b` and `c` that defines the vector(s)
+        and cross product(s).  Overrides `axisa`, `axisb` and `axisc`.
+
+    Returns
+    -------
+    c : ndarray
 
 Review comment:
   `c : _Symbol`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #17573: [Numpy] Add cross product op

Posted by GitBox <gi...@apache.org>.
haojin2 commented on a change in pull request #17573: [Numpy] Add cross product op
URL: https://github.com/apache/incubator-mxnet/pull/17573#discussion_r378652550
 
 

 ##########
 File path: python/mxnet/ndarray/numpy/_op.py
 ##########
 @@ -44,7 +44,7 @@
            'tril', 'identity', 'take', 'ldexp', 'vdot', 'inner', 'outer',
            'equal', 'not_equal', 'greater', 'less', 'greater_equal', 'less_equal', 'hsplit', 'rot90', 'einsum',
            'true_divide', 'nonzero', 'quantile', 'percentile', 'shares_memory', 'may_share_memory',
-           'diff', 'resize', 'nan_to_num', 'isnan', 'isinf', 'where', 'bincount']
+           'diff', 'resize', 'nan_to_num', 'isnan', 'isinf', 'where', 'bincount', 'cross']
 
 Review comment:
   move this to after 'outer', same for all python wrappers

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #17573: [Numpy] Add cross product op

Posted by GitBox <gi...@apache.org>.
haojin2 commented on a change in pull request #17573: [Numpy] Add cross product op
URL: https://github.com/apache/incubator-mxnet/pull/17573#discussion_r378652813
 
 

 ##########
 File path: python/mxnet/symbol/numpy/_symbol.py
 ##########
 @@ -6160,4 +6160,56 @@ def bincount(x, weights=None, minlength=0):
     return _npi.bincount(x, weights=weights, minlength=minlength, has_weights=True)
 
 
+@set_module('mxnet.symbol.numpy')
+def cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None, **kwargs): # pylint: disable=too-many-arguments
+    """
+    Return the cross product of two (arrays of) vectors.
+
+    The cross product of `a` and `b` in :math:`R^3` is a vector perpendicular
+    to both `a` and `b`.  If `a` and `b` are arrays of vectors, the vectors
+    are defined by the last axis of `a` and `b` by default, and these axes
+    can have dimensions 2 or 3.  Where the dimension of either `a` or `b` is
+    2, the third component of the input vector is assumed to be zero and the
+    cross product calculated accordingly.  In cases where both input vectors
+    have dimension 2, the z-component of the cross product is returned.
+
+    Parameters
+    ----------
+    a : ndarray
 
 Review comment:
   `a : _Symbol`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] sjtuWangDing closed pull request #17573: [Numpy] Add cross product op

Posted by GitBox <gi...@apache.org>.
sjtuWangDing closed pull request #17573: [Numpy] Add cross product op
URL: https://github.com/apache/incubator-mxnet/pull/17573
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services