Skip to content

Commit

Permalink
[torch_xla2] add igammac (#8298)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfeiBai authored Oct 22, 2024
1 parent 25fc630 commit ff43125
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 0 additions & 1 deletion experimental/torch_xla2/test/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"geqrf",
"histogram", # hard op: AssertionError: Tensor-likes are not close!
"histogramdd", # TypeError: histogram requires ndarray or scalar arguments, got <class 'list'> at position 1.
"igammac",
"index_reduce",
"kthvalue",
"linalg.cholesky",
Expand Down
13 changes: 13 additions & 0 deletions experimental/torch_xla2/torch_xla2/ops/jaten.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ def _aten_index_select(x, dim, index):
return jnp.take(x, index, dim)


# aten.igammac
@op(torch.ops.aten.igammac)
def _aten_igammac(input, other):
if isinstance(input, jnp.ndarray):
input = jnp.where(input < 0, jnp.nan, input)
if isinstance(other, jnp.ndarray):
other = jnp.where(other < 0, jnp.nan, other)
else:
if (input==0 and other==0) or (input < 0) or (other < 0):
other = jnp.nan
return jnp.array(jax.scipy.special.gammaincc(input, other))


@op(torch.ops.aten.mean)
def _aten_mean(x, dim=None, keepdim=False):
if x.shape == () and dim is not None:
Expand Down

0 comments on commit ff43125

Please sign in to comment.