Skip to content

Commit 8404a51

Browse files
authored
[KUNLUNXIN] Speed Up exp2 (#1254)
1 parent a34a3d0 commit 8404a51

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

  • src/flag_gems/runtime/backend/_kunlunxin/ops

src/flag_gems/runtime/backend/_kunlunxin/ops/exp2.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,27 @@
22

33
import triton
44
import triton.language as tl
5+
from _kunlunxin.utils.codegen_config_utils import CodeGenConfig
56

67
from ..utils.pointwise_dynamic import pointwise_dynamic
78

8-
logger = logging.getLogger("flag_gems").getChild(__name__.lstrip("."))
9+
logger = logging.getLogger(__name__)
910

11+
config_ = CodeGenConfig(
12+
512,
13+
(65536, 65536, 65536),
14+
32,
15+
True,
16+
prefer_1d_tile=True,
17+
buffer_size_limit=4096,
18+
unroll_num=8,
19+
)
1020

11-
@pointwise_dynamic(promotion_methods=[(0, "INT_TO_FLOAT")])
21+
22+
@pointwise_dynamic(promotion_methods=[(0, "INT_TO_FLOAT")], config=config_)
1223
@triton.jit
1324
def exp2_func(x):
14-
LN2 = 0.69314718056
15-
return tl.exp(x.to(tl.float32) * LN2)
25+
return tl.exp2(x.to(tl.float32))
1626

1727

1828
def exp2(A):

0 commit comments

Comments
 (0)