Coverage for src/flag_gems/runtime/backend/_kunlunxin/ops/polar.py: 0%
14 statements
« prev ^ index » next coverage.py v7.6.9, created at 2026-03-24 15:40 +0800
« prev ^ index » next coverage.py v7.6.9, created at 2026-03-24 15:40 +0800
1import torch
2import triton
3import triton.language as tl
5from ..utils.pointwise_dynamic import pointwise_dynamic
8@pointwise_dynamic(
9 promotion_methods=[
10 ((0, 1), "DEFAULT"),
11 ((0, 1), "DEFAULT"),
12 ],
13 num_outputs=2,
14)
15@triton.jit
16def polar_kernel(abs, angle):
17 real = abs * tl.cos(angle)
18 imag = abs * tl.sin(angle)
19 return real, imag
22def polar(abs, angle):
23 output = torch.empty((*abs.shape, 2), dtype=abs.dtype, device=abs.device)
25 polar_kernel(abs, angle, out0=output[..., 0], out1=output[..., 1])
27 return torch.view_as_complex(output)