cuda.tile.atan2#

cuda.tile.atan2(x1, x2, /)#

Elementwise atan2 of two tiles.

Computes the element-wise arc tangent of x1/x2 choosing the quadrant correctly.

Parameters:
  • x1 (Tile) – Numerator tile (y-coordinate).

  • x2 (Tile) – Denominator tile (x-coordinate).

The shape of x1 and x2 will be broadcasted and dtype promoted to common dtype.

Returns:

The angles in radians, in the range [-pi, pi].

Return type:

Tile

Examples

y = ct.full((4,), 1.0, dtype=ct.float32)
x = ct.full((4,), 0.0, dtype=ct.float32)
print(f"{ct.atan2(y, x):.4f}")
import cuda.tile as ct
import torch

@ct.kernel
def kernel():
    y = ct.full((4,), 1.0, dtype=ct.float32)
    x = ct.full((4,), 0.0, dtype=ct.float32)
    print(f"{ct.atan2(y, x):.4f}")


torch.cuda.init()
ct.launch(torch.cuda.current_stream(), (1,), kernel, ())
torch.cuda.synchronize()

Output

[1.5708, 1.5708, 1.5708, 1.5708]