-
Notifications
You must be signed in to change notification settings - Fork 88
Implement broadcast* routines #458
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
Conversation
|
@sbak5 : it seems like all the tests a failing. Could you, please, have a look ? |
Yes. Already prepared a fix and testing on a local machine before pushing it. |
|
I think there are tests for |
|
Yes, I think it would be nice to have separate tests |
|
Can you replace all calls to |
behave correctly for an array manipulation routine
| else: | ||
| self.array = np.flip(rhs.array, axes) | ||
|
|
||
| def broadcast_to(self, shape: NdShape) -> NumPyThunk: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code doesn't make sense at all. why is an eager array always converted to a deferred array here? can't this be implemented using numpy.broadcast_to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I remember, this was intended to handle a case when eager and deferred array are used for a operation. In this case, a broadcasted eager array should be changed to a corresponding deferred array, which doesn't work w/ deferred.broadcast_to. So, I changed this code to convert eager array to deferred when broadcast_tois called. I couldn't find a way to handle this case on my own w/o this change.
| broadcasted: bool = False, | ||
| ) -> ndarray: | ||
| # create an array object w/ options passed from 'broadcast' routines | ||
| arr = array(arr, copy=False, subok=subok) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the point of this call? note that subok isn't handled in array anyway, so this is a no-op.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
broadcast has the argument and numpy.array in cuNumeric still has the argument even though it's not implemented for subclasses. This call is just aligned with the corresponding routines so that there's no need to change this call when subclasses are implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@magnatelee do you have a follow-up to the previous reply? I don't have enough context to know what is appropriate here (and below)
| subok: bool = False, | ||
| ) -> list[ndarray]: | ||
| # create an arry object w/ options passed from 'broadcast' routines | ||
| arrays = [array(arr, copy=False, subok=subok) for arr in arrs] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment here. why is this necessary?
|
@sbak5 it looks like NumPy's |
This is because of the runtime issue in legion as far as I remember. |
|
As a start, brought up to date with current |
Co-authored-by: Wonchan Lee <Magnate.Lee@gmail.com>
for more information, see https://pre-commit.ci
…into sbak5/broadcast
|
@ipdemes @magnatelee I have made a quick stab at bringing this PR up to date with the latest branch, and also addressing some of the low-hanging suggestions. There's a lot of comments and history here. For my own sake, would you mind if I copied all of this over to a new PR branch and cleaned up the commit history with an interactive rebase, then started on a new review there? |
Not at all. I'd be happy to do a fresh review. Please go open a new PR. |
|
closing, superseded by #759 |
* enhance for random --------- Co-authored-by: Jacob Faibussowitsch <jacob.fai@gmail.com>
Implementation of the following routines
These routines follow the behavior of the corresponding numpy routines.