Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add numpy array like operations to DistributedMatrix #14

Open
zuoshifan opened this issue Nov 17, 2014 · 1 comment
Open

Add numpy array like operations to DistributedMatrix #14

zuoshifan opened this issue Nov 17, 2014 · 1 comment

Comments

@zuoshifan
Copy link
Collaborator

Do you have some interests to provide the DistributedMatrix class with some numpy array like operations, such as slicing, so one could easily do the following calculations but leaves all the tricky details of MPI and distribution behand?

a = np.arange(10, dtype=np.float64)
A = core.DistributedMatrix([10, 20], dtype=a.dtype, block_shape=[2, 3])
A[0, :10] = a

b = np.zeros(10, dtype=np.float64)
b = A[0, :10]
assert np.allclose(a, b)
@jrs65
Copy link
Owner

jrs65 commented Nov 18, 2014

Good question, I've wondered about allowing this kind of stuff a little more, though I hadn't thought in particular about the slicing aspect. There's a complicated design question of how much do we want the DistributedMatrix class to look like a numpy array, so do we want to support these kind of operations.

In the case of the slicing as you've written it, I guess it could be implemented pretty easily with calls to pxgemr2d, similar to DistributedMatrix.redistribute.

Other things I've wondered about would be:

  • Supporting the various standard elementwise operators: +, -, *, /, **. This could be done pretty easily by just overloading the operators.
  • Adding support for numpy ufuncs (e.g. np.exp). This may require making DistributedMatrix a numpy subclass which would be much more involved.

Does anyone have any opinions on this idea in general, or these three specific parts? @zuoshifan @kiyo-masui @kmsmith137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants