pyamgx icon indicating copy to clipboard operation
pyamgx copied to clipboard

Feature request: generic interface for pyamgx.Vector.download( )

Open qingshanchen opened this issue 4 years ago • 2 comments

Currently pyamgx.Vector has the method download( ) for numpy arrays, and download_raw( ) for raw pointers (possibly on GPU?) Raw pointers are rather difficult to use. I hope that a generic interface can be implemented for the Vector.download( ) method, which can download data either to a numpy array variable, or a cupy array variable, just like the Vector.upload( ) method and the Matrix.upload( ) method. Many thanks!

qingshanchen avatar Feb 08 '21 18:02 qingshanchen

A single API for copying to both host and device is a bit confusing. What do you think about distinct download_host and download_device functions?


class Vector:

    def download_host(self, out: np.ndarray=None):
        """Copies the contents of the vector to the given NumPy array `out`.
           If `out` is not given, a new NumPy array is returned
        """
        pass
        
    def download_device(self, out: cp.ndarray=None):
        """Copies the contents of the vector to the given CuPy array `out`.
           If `out` is not given, a new CuPy array is returned
        """
        pass

shwina avatar Mar 01 '21 23:03 shwina

Yes, this should work. Thanks a lot!

I agree that a single download for both host and device is confusing. The current download_raw is a bit primitive.

On Mar 1, 2021, at 6:36 PM, Ashwin Srinath [email protected] wrote:



A single API for both host and device is a bit confusing. What do you think about distinct download_host and download_device functions?

class Vector:

def download_host(self, out: np.ndarray=None):
    """Copies the contents of the vector to the given NumPy array `out`.
         If `out` is not given, a new NumPy array is returned
    """
    pass

def download_device(self, out: cp.ndarray=None):
    """Copies the contents of the vector to the given CuPy array `out`.
         If `out` is not given, a new CuPy array is returned
    """
    pass

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/shwina/pyamgx/issues/26#issuecomment-788400283, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA75WFFG44FA6BVY7Z6S7ILTBQQHHANCNFSM4XJPT2IQ.

qingshanchen avatar Mar 02 '21 02:03 qingshanchen