-
Notifications
You must be signed in to change notification settings - Fork 54
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 out
and where
args for ht.div
#945
Changes from 4 commits
1b865c9
ecb28cc
2755448
28dcca7
2a0c14b
cecbb41
f8ed24a
c8b33ce
b673091
03f288a
bdeed00
1ccbf7a
99316a6
a39dcb6
067c36e
9d2926b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
from typing import Optional, Union, Tuple | ||
|
||
from . import factories | ||
from . import indexing | ||
from . import manipulations | ||
from . import _operations | ||
from . import sanitation | ||
|
@@ -427,7 +428,12 @@ def diff( | |
return ret | ||
|
||
|
||
def div(t1: Union[DNDarray, float], t2: Union[DNDarray, float]) -> DNDarray: | ||
def div( | ||
t1: Union[DNDarray, float], | ||
t2: Union[DNDarray, float], | ||
out: Optional[DNDarray] = None, | ||
where: Optional[DNDarray] = None, | ||
) -> DNDarray: | ||
""" | ||
Element-wise true division of values of operand ``t1`` by values of operands ``t2`` (i.e ``t1/t2``). | ||
Operation is not commutative. | ||
|
@@ -438,6 +444,10 @@ def div(t1: Union[DNDarray, float], t2: Union[DNDarray, float]) -> DNDarray: | |
The first operand whose values are divided | ||
t2: DNDarray or scalar | ||
The second operand by whose values is divided | ||
out: DNDarray, optional | ||
The output array. It must have a shape that the inputs broadcast to | ||
where: DNDarray, optional | ||
Condition of interest, where true yield divided value else yield original value in t1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should follow |
||
|
||
Example | ||
--------- | ||
|
@@ -453,7 +463,10 @@ def div(t1: Union[DNDarray, float], t2: Union[DNDarray, float]) -> DNDarray: | |
DNDarray([[2.0000, 1.0000], | ||
[0.6667, 0.5000]], dtype=ht.float32, device=cpu:0, split=None) | ||
""" | ||
return _operations.__binary_op(torch.true_divide, t1, t2) | ||
if where is not None: | ||
t2 = indexing.where(where, t2, 1) | ||
|
||
return _operations.__binary_op(torch.true_divide, t1, t2, out) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should return So the way to go here would be to modify |
||
|
||
|
||
DNDarray.__truediv__ = lambda self, other: div(self, other) | ||
|
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.
shape and
split
dimension