-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from Bowen12992/where_op
Add where op
- Loading branch information
Showing
6 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import torch | ||
import triton | ||
import triton.language as tl | ||
import logging | ||
from ..utils import pointwise_dynamic | ||
|
||
|
||
@pointwise_dynamic(is_tensor=[True, True, True]) | ||
@triton.jit | ||
def where_self_func(self, condition, other): | ||
return tl.where(condition, self, other) | ||
|
||
|
||
def where_self(condition, self, other): | ||
logging.debug("GEMS WHERE_SELF") | ||
O = where_self_func(self, condition, other) | ||
return O | ||
|
||
|
||
@pointwise_dynamic(is_tensor=[True, True, False]) | ||
@triton.jit | ||
def where_scalar_self_func(other, condition, self): | ||
return tl.where(condition, self, other) | ||
|
||
|
||
def where_scalar_self(condition, self, other): | ||
logging.debug("GEMS WHERE_SCALAR_SELF") | ||
O = where_scalar_self_func(other, condition, self) | ||
return O | ||
|
||
|
||
@pointwise_dynamic(is_tensor=[True, True, False]) | ||
@triton.jit | ||
def where_scalar_other_func(self, condition, other): | ||
return tl.where(condition, self, other) | ||
|
||
|
||
def where_scalar_other(condition, self, other): | ||
logging.debug("GEMS WHERE_SCALAR_OTHER") | ||
O = where_scalar_other_func(self, condition, other) | ||
return O |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters