Skip to content

Commit

Permalink
Adds torch.nn.functional.cosine_similarity Jax implementation (#8305)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlinntu authored Oct 30, 2024
1 parent 89e47b3 commit c9e02e9
Show file tree
Hide file tree
Showing 2 changed files with 5 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 @@ -39,7 +39,6 @@
"nn.functional.conv_transpose2d",
"nn.functional.conv_transpose3d",
"nn.functional.cosine_embedding_loss",
"nn.functional.cosine_similarity",
"nn.functional.ctc_loss",
"nn.functional.dropout2d",
"nn.functional.dropout3d",
Expand Down
5 changes: 5 additions & 0 deletions experimental/torch_xla2/torch_xla2/ops/jaten.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
# squeeze_ is expected to change tensor's shape. So replace with new value
torch.ops.aten.squeeze_: (torch.ops.aten.squeeze, True),
torch.ops.aten.clamp_: torch.ops.aten.clamp,
torch.ops.aten.clamp_min_: torch.ops.aten.clamp_min,
torch.ops.aten.ceil_: torch.ops.aten.ceil,
torch.ops.aten.logical_not_: torch.ops.aten.logical_not,
torch.ops.aten.unsqueeze_: torch.ops.aten.unsqueeze,
Expand Down Expand Up @@ -2158,6 +2159,10 @@ def _aten_broadcast_to(input, shape):
def _aten_clamp(self, min=None, max=None):
return jnp.clip(self, min, max)

@op(torch.ops.aten.clamp_min)
def _aten_clamp_min(input, min):
return jnp.clip(input, min=min)


# aten.constant_pad_nd
@op(torch.ops.aten.constant_pad_nd)
Expand Down

0 comments on commit c9e02e9

Please sign in to comment.