Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added LinSpace to Raw_Ops for tf frontends #10871

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ivy/functional/frontends/tensorflow/raw_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,3 +607,9 @@ def Elu(features, name=None):
"float64",
),
}


# @with_unsupported_dtypes({"2.9.1 and below": ()}, "tensorflow")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! thanks for your quick response. I will correct this.

@to_ivy_arrays_and_back
def LinSpace(*, start, stop, num, name=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These arguments are not keyword-only, you can remove *

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for this, the test is now failing with an error as follows:

E       TypeError: lin_space only takes keyword args (possible keys: ['start', 'stop', 'num', 'name']). Please pass these args as kwargs instead.
../../mambaforge/envs/ivy_dev/lib/python3.8/site-packages/tensorflow/python/util/tf_export.py:396: TypeError

Copy link
Contributor Author

@sdk2k01 sdk2k01 Feb 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a related error I found on the issue, if that helps (apologies if I'm being wrong somewhere).

Also, here's another (plausible) source to support my statement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, You're right, I wasn't aware of that.
Thanks for clearing that up 😄

return ivy.linspace(start, stop, num)
55 changes: 55 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_tensorflow/test_raw_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -3057,3 +3057,58 @@ def test_tensorflow_Elu(
features=x[0],
name=name,
)


@st.composite
def _LinSpace_helper(draw):
shape = ()
dtype = draw(st.sampled_from(["float32", "float64"]))

# Param: start
start = draw(
helpers.array_values(
dtype=dtype,
shape=shape,
min_value=-5.0,
max_value=5.0,
),
)

# Param: stop
stop = draw(
helpers.array_values(
dtype=dtype,
shape=shape,
min_value=-4.0,
max_value=10.0,
),
)

return [dtype] * 2, start, stop


@handle_frontend_test(
fn_tree="tensorflow.raw_ops.LinSpace",
dtype_and_params=_LinSpace_helper(),
num=helpers.ints(min_value=2, max_value=10),
)
def test_tensorflow_LinSpace(
*,
dtype_and_params,
num,
on_device,
fn_tree,
frontend,
test_flags,
):
dtype, start, stop = dtype_and_params
helpers.test_frontend_function(
input_dtypes=dtype,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
start=start,
stop=stop,
num=num,
on_device=on_device,
)