forked from flagos-ai/FlagGems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrsub.py
More file actions
31 lines (20 loc) · 675 Bytes
/
Copy pathrsub.py
File metadata and controls
31 lines (20 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import logging
import triton
from flag_gems.utils import pointwise_dynamic
logger = logging.getLogger(__name__)
@pointwise_dynamic(is_tensor=[True, True, False], promotion_methods=[(0, 1, "DEFAULT")])
@triton.jit
def rsub_func(x, y, alpha):
return y - x * alpha
@pointwise_dynamic(
is_tensor=[True, False, False], promotion_methods=[(0, 1, "DEFAULT")]
)
@triton.jit
def rsub_func_tensor_scalar(x, y, alpha):
return y - x * alpha
def rsub_tensor(A, B, *, alpha=1):
logger.debug("GEMS RSUB_TENSOR")
return rsub_func(A, B, alpha)
def rsub_scalar(A, B, alpha=1):
logger.debug("GEMS RSUB_SCALAR")
return rsub_func_tensor_scalar(A, B, alpha)