mozga-intel commented on a change in pull request #20633:
URL: https://github.com/apache/incubator-mxnet/pull/20633#discussion_r721965415



##########
File path: python/mxnet/numpy/linalg.py
##########
@@ -67,6 +70,53 @@ def matrix_rank(M, tol=None, hermitian=False):
     return _mx_nd_np.linalg.matrix_rank(M, tol, hermitian)
 
 
+def vecdot(a: ndarray, b, ndarray, axis: Optional[int] =None) -> ndarray:
+    r"""
+    Return the dot product of two vectors.
+    Note that `vecdot` handles multidimensional arrays differently than `dot`:
+    it does *not* perform a matrix product, but flattens input arguments
+    to 1-D vectors first. Consequently, it should only be used for vectors.
+
+    Parameters
+    ----------
+    a : ndarray
+        First argument to the dot product.
+    b : ndarray
+        Second argument to the dot product.
+    axis : axis over which to compute the dot product. Must be an integer on
+        the interval [-N, N) , where N is the rank (number of dimensions) of
+        the shape determined according to Broadcasting . If specified as a
+        negative integer, the function must determine the axis along which
+        to compute the dot product by counting backward from the last dimension
+        (where -1 refers to the last dimension). If None , the function must
+        compute the dot product over the last axis. Default: None .
+
+    Returns
+    -------
+    output : ndarray
+        Dot product of `a` and `b`.
+
+    See Also
+    --------
+    dot : Return the dot product without using the complex conjugate of the
+        first argument.
+
+    Examples
+    --------
+    Note that higher-dimensional arrays are flattened!
+
+    >>> a = np.array([[1, 4], [5, 6]])
+    >>> b = np.array([[4, 1], [2, 2]])
+    >>> np.vecdot(a, b)
+    array(30.)
+    >>> np.vecdot(b, a)

Review comment:
       The same here.

##########
File path: python/mxnet/numpy/linalg.py
##########
@@ -67,6 +70,53 @@ def matrix_rank(M, tol=None, hermitian=False):
     return _mx_nd_np.linalg.matrix_rank(M, tol, hermitian)
 
 
+def vecdot(a: ndarray, b, ndarray, axis: Optional[int] =None) -> ndarray:
+    r"""
+    Return the dot product of two vectors.
+    Note that `vecdot` handles multidimensional arrays differently than `dot`:
+    it does *not* perform a matrix product, but flattens input arguments
+    to 1-D vectors first. Consequently, it should only be used for vectors.
+
+    Parameters
+    ----------
+    a : ndarray
+        First argument to the dot product.
+    b : ndarray
+        Second argument to the dot product.
+    axis : axis over which to compute the dot product. Must be an integer on
+        the interval [-N, N) , where N is the rank (number of dimensions) of
+        the shape determined according to Broadcasting . If specified as a
+        negative integer, the function must determine the axis along which
+        to compute the dot product by counting backward from the last dimension
+        (where -1 refers to the last dimension). If None , the function must
+        compute the dot product over the last axis. Default: None .

Review comment:
       ```suggestion
           compute the dot product over the last axis. Default: None.
   ```

##########
File path: python/mxnet/numpy/linalg.py
##########
@@ -67,6 +70,53 @@ def matrix_rank(M, tol=None, hermitian=False):
     return _mx_nd_np.linalg.matrix_rank(M, tol, hermitian)
 
 
+def vecdot(a: ndarray, b, ndarray, axis: Optional[int] =None) -> ndarray:
+    r"""
+    Return the dot product of two vectors.
+    Note that `vecdot` handles multidimensional arrays differently than `dot`:
+    it does *not* perform a matrix product, but flattens input arguments
+    to 1-D vectors first. Consequently, it should only be used for vectors.
+
+    Parameters
+    ----------
+    a : ndarray
+        First argument to the dot product.
+    b : ndarray
+        Second argument to the dot product.
+    axis : axis over which to compute the dot product. Must be an integer on
+        the interval [-N, N) , where N is the rank (number of dimensions) of
+        the shape determined according to Broadcasting . If specified as a
+        negative integer, the function must determine the axis along which
+        to compute the dot product by counting backward from the last dimension
+        (where -1 refers to the last dimension). If None , the function must

Review comment:
       ```suggestion
           (where -1 refers to the last dimension). If None, the function must
   ```

##########
File path: python/mxnet/numpy/linalg.py
##########
@@ -67,6 +70,53 @@ def matrix_rank(M, tol=None, hermitian=False):
     return _mx_nd_np.linalg.matrix_rank(M, tol, hermitian)
 
 
+def vecdot(a: ndarray, b, ndarray, axis: Optional[int] =None) -> ndarray:

Review comment:
       ```def vecdot(a: ndarray, b, ndarray, axis: Optional[int] =None) -> 
ndarray:```
   How about adding the same function style in the entire file by giving the 
type-name explicitly?

##########
File path: python/mxnet/numpy/linalg.py
##########
@@ -67,6 +70,53 @@ def matrix_rank(M, tol=None, hermitian=False):
     return _mx_nd_np.linalg.matrix_rank(M, tol, hermitian)
 
 
+def vecdot(a: ndarray, b, ndarray, axis: Optional[int] =None) -> ndarray:
+    r"""
+    Return the dot product of two vectors.
+    Note that `vecdot` handles multidimensional arrays differently than `dot`:
+    it does *not* perform a matrix product, but flattens input arguments
+    to 1-D vectors first. Consequently, it should only be used for vectors.
+
+    Parameters
+    ----------
+    a : ndarray
+        First argument to the dot product.
+    b : ndarray
+        Second argument to the dot product.
+    axis : axis over which to compute the dot product. Must be an integer on
+        the interval [-N, N) , where N is the rank (number of dimensions) of
+        the shape determined according to Broadcasting . If specified as a
+        negative integer, the function must determine the axis along which
+        to compute the dot product by counting backward from the last dimension
+        (where -1 refers to the last dimension). If None , the function must
+        compute the dot product over the last axis. Default: None .
+
+    Returns
+    -------
+    output : ndarray
+        Dot product of `a` and `b`.
+
+    See Also
+    --------
+    dot : Return the dot product without using the complex conjugate of the
+        first argument.
+
+    Examples
+    --------
+    Note that higher-dimensional arrays are flattened!
+
+    >>> a = np.array([[1, 4], [5, 6]])
+    >>> b = np.array([[4, 1], [2, 2]])
+    >>> np.vecdot(a, b)

Review comment:
       ```suggestion
       >>> np.linalg.vecdot(a, b)
   ```

##########
File path: python/mxnet/numpy/linalg.py
##########
@@ -67,6 +70,53 @@ def matrix_rank(M, tol=None, hermitian=False):
     return _mx_nd_np.linalg.matrix_rank(M, tol, hermitian)
 
 
+def vecdot(a: ndarray, b, ndarray, axis: Optional[int] =None) -> ndarray:
+    r"""
+    Return the dot product of two vectors.
+    Note that `vecdot` handles multidimensional arrays differently than `dot`:
+    it does *not* perform a matrix product, but flattens input arguments
+    to 1-D vectors first. Consequently, it should only be used for vectors.
+
+    Parameters
+    ----------
+    a : ndarray
+        First argument to the dot product.
+    b : ndarray
+        Second argument to the dot product.
+    axis : axis over which to compute the dot product. Must be an integer on
+        the interval [-N, N) , where N is the rank (number of dimensions) of
+        the shape determined according to Broadcasting . If specified as a

Review comment:
       ```suggestion
           the shape determined according to Broadcasting. If specified as a
   ```

##########
File path: python/mxnet/numpy/linalg.py
##########
@@ -839,7 +889,8 @@ def eigvals(a):
     return _mx_nd_np.linalg.eigvals(a)
 
 
-def eigvalsh(a, UPLO='L'):
+@wrap_data_api_linalg_func
+def eigvalsh(a, upper=False):

Review comment:
       Should Cholesky take a special param `upper=False`? 
[link](https://github.com/apache/incubator-mxnet/pull/20633/files#diff-ea841d142011d5eecb5db0d91a54f8e60db58da7ae51a02145ecdb4ea50ffb9eR394).
 According to 
[link](https://data-apis.org/array-api/latest/extensions/linear_algebra_functions.html#linalg-cholesky-x-upper-false)
 , a new one op should have additional param. 

##########
File path: python/mxnet/numpy/linalg.py
##########
@@ -67,6 +70,53 @@ def matrix_rank(M, tol=None, hermitian=False):
     return _mx_nd_np.linalg.matrix_rank(M, tol, hermitian)
 
 
+def vecdot(a: ndarray, b, ndarray, axis: Optional[int] =None) -> ndarray:
+    r"""
+    Return the dot product of two vectors.
+    Note that `vecdot` handles multidimensional arrays differently than `dot`:
+    it does *not* perform a matrix product, but flattens input arguments
+    to 1-D vectors first. Consequently, it should only be used for vectors.
+
+    Parameters
+    ----------
+    a : ndarray
+        First argument to the dot product.
+    b : ndarray
+        Second argument to the dot product.
+    axis : axis over which to compute the dot product. Must be an integer on
+        the interval [-N, N) , where N is the rank (number of dimensions) of
+        the shape determined according to Broadcasting . If specified as a
+        negative integer, the function must determine the axis along which
+        to compute the dot product by counting backward from the last dimension
+        (where -1 refers to the last dimension). If None , the function must
+        compute the dot product over the last axis. Default: None .
+
+    Returns
+    -------
+    output : ndarray
+        Dot product of `a` and `b`.
+
+    See Also
+    --------
+    dot : Return the dot product without using the complex conjugate of the
+        first argument.
+
+    Examples
+    --------
+    Note that higher-dimensional arrays are flattened!
+
+    >>> a = np.array([[1, 4], [5, 6]])
+    >>> b = np.array([[4, 1], [2, 2]])
+    >>> np.vecdot(a, b)
+    array(30.)
+    >>> np.vecdot(b, a)
+    array(30.)
+    >>> 1*4 + 4*1 + 5*2 + 6*2
+    30
+    """
+    return tensordot(a.flatten(), b.flatten(), axis)

Review comment:
       It looks like that tensordot does not exist in the current context. 
Please use `_mx_nd_np.tensordot(a.flatten(), b.flatten(), axis)`

##########
File path: python/mxnet/numpy/linalg.py
##########
@@ -67,6 +70,53 @@ def matrix_rank(M, tol=None, hermitian=False):
     return _mx_nd_np.linalg.matrix_rank(M, tol, hermitian)
 
 
+def vecdot(a: ndarray, b, ndarray, axis: Optional[int] =None) -> ndarray:

Review comment:
       ```suggestion
   def vecdot(a: ndarray, b: ndarray, axis: Optional[int]=None) -> ndarray:
   ```

##########
File path: python/mxnet/numpy/linalg.py
##########
@@ -67,6 +70,53 @@ def matrix_rank(M, tol=None, hermitian=False):
     return _mx_nd_np.linalg.matrix_rank(M, tol, hermitian)
 
 
+def vecdot(a: ndarray, b, ndarray, axis: Optional[int] =None) -> ndarray:

Review comment:
       How about maintaining consistency in this file? the function above 
should take and return format inexplicitly; without `-> ndarray` annotation. If 
you want to keep the standard like this: then it could be nice to have all 
functions changed.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to