Skip to content

Commit

Permalink
feat: add log_softmax torch frontend Tenor method and the test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishticode committed Feb 14, 2024
1 parent 3a8f810 commit 6b40c71
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ivy/functional/frontends/torch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,10 @@ def fmax(self, other):
def fmin(self, other):
return torch_frontend.fmin(self, other)

@with_unsupported_dtypes({"2.2 and below": ("float16",)}, "torch")
def log_softmax(self, dim=None, _stack_level=3, dtype=None):
return torch_frontend.nn.functional.log_softmax(self, dim=dim, dtype=dtype)

def msort(self):
return torch_frontend.msort(self)

Expand Down
45 changes: 45 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8824,6 +8824,51 @@ def test_torch_log_(
)


@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="torch.tensor",
method_name="log_softmax",
dtype_x_and_axis=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("float"),
min_num_dims=1,
max_axes_size=1,
force_int_axis=True,
valid_axis=True,
),
dtypes=helpers.get_dtypes("float", none=False, full=False),
)
def test_torch_log_softmax(
*,
dtype_x_and_axis,
dtypes,
on_device,
frontend,
backend_fw,
frontend_method_data,
init_flags,
method_flags,
):
input_dtype, x, axis = dtype_x_and_axis

helpers.test_frontend_method(
init_input_dtypes=input_dtype,
backend_to_test=backend_fw,
init_all_as_kwargs_np={
"data": x[0],
},
method_input_dtypes=input_dtype,
method_all_as_kwargs_np={
"dim": axis,
"dtype": dtypes[0],
},
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
frontend=frontend,
on_device=on_device,
)


# logaddexp
@handle_frontend_method(
class_tree=CLASS_TREE,
Expand Down

0 comments on commit 6b40c71

Please sign in to comment.