Skip to content

Resolve: [Good First Issue][Keras 3 OpenVINO Backend]: Support numpy.linspace operation #29485 #21140

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

VLTisME
Copy link

@VLTisME VLTisME commented Apr 6, 2025

Reduced failed tests to 2 failed and 12 skipped.
two left unsolved failed tests:
1/
start = 0, stop = 10, num = <tf.Tensor: shape=(), dtype=int32, numpy=5>
endpoint = True, retstep = False, dtype = None, axis = 0

@keras_export(["keras.ops.linspace", "keras.ops.numpy.linspace"])
def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0, *, device=None):
    # Validate num
    if not isinstance(num, int):
      raise TypeError("num must be an integer")

E TypeError: num must be an integer

2/

  arrays = [np.empty(x, dtype=[]) for x in args]

E TypeError: 'NoneType' object cannot be interpreted as an integer

Copy link

google-cla bot commented Apr 6, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@VLTisME
Copy link
Author

VLTisME commented Apr 6, 2025

@rkazants may you review this?

@VLTisME
Copy link
Author

VLTisME commented Apr 6, 2025

I have collected some errors, gonna fix it:
1/

      start_np, stop_np = np.broadcast_arrays(start.numpy(), stop.numpy())

E AttributeError: 'OpenVINOKerasTensor' object has no attribute 'numpy'
2/

      start_np, stop_np = np.broadcast_arrays(start.numpy(), stop.numpy())

E AttributeError: 'numpy.ndarray' object has no attribute 'numpy'. Did you mean: 'dump'?
3/
if backend.shape(start) == () and backend.shape(stop) == ():
result = start + indices * step
else:

      start_np, stop_np = np.broadcast_arrays(start.numpy(), stop.numpy())

E AttributeError: 'jaxlib.xla_extension.ArrayImpl' object has no attribute 'numpy'
4/
def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0, *, device=None):
if not isinstance(num, int):

      raise TypeError("num must be an integer")

E TypeError: num must be an integer
5/

arrays = [np.empty(x, dtype=[]) for x in args]
E TypeError: 'NoneType' object cannot be interpreted as an integer

@gbaned gbaned requested a review from mattdangerw April 8, 2025 10:20
@gbaned gbaned added this to PR Queue Apr 8, 2025
@github-project-automation github-project-automation bot moved this to Assigned Reviewer in PR Queue Apr 8, 2025
@@ -3468,51 +3468,100 @@ def compute_output_spec(self, start, stop):

Copy link
Contributor

Choose a reason for hiding this comment

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

pytest.ini Outdated
@@ -0,0 +1,3 @@
[pytest]
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove this file. It is needed only for developer purpose

@codecov-commenter
Copy link

codecov-commenter commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.

Project coverage is 80.08%. Comparing base (44a655b) to head (95ed578).

Files with missing lines Patch % Lines
keras/src/backend/openvino/numpy.py 0.00% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21140      +/-   ##
==========================================
- Coverage   82.74%   80.08%   -2.66%     
==========================================
  Files         564      564              
  Lines       54199    54218      +19     
  Branches     8418     8424       +6     
==========================================
- Hits        44845    43419    -1426     
- Misses       7283     8788    +1505     
+ Partials     2071     2011      -60     
Flag Coverage Δ
keras 79.89% <0.00%> (-2.66%) ⬇️
keras-jax 63.93% <0.00%> (-0.03%) ⬇️
keras-numpy 59.04% <0.00%> (-0.03%) ⬇️
keras-openvino ?
keras-tensorflow 64.31% <0.00%> (-0.03%) ⬇️
keras-torch 64.01% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

\q
ranch 'linspace_func' of https://github.com/VLTisME/keras_forked into linspace_func
@rkazants
Copy link
Contributor

@VLTisME, please fix test failures, see CI logs:

FAILED keras/src/ops/numpy_test.py::NumpyTwoInputOpsCorrectnessTest::test_linspace - TypeError: unsupported operand type(s) for -: 'openvino._pyopenvino.Output' and 'openvino._pyopenvino.Output'
FAILED keras/src/ops/numpy_test.py::NumpyDtypeTest::test_linspace_[0, 10]_0_bfloat16 - TypeError: unsupported operand type(s) for -: 'openvino._pyopenvino.Output' and 'openvino._pyopenvino.Output'
FAILED keras/src/ops/numpy_test.py::NumpyDtypeTest::test_linspace_[0, 10]_0_float16 - TypeError: unsupported operand type(s) for -: 'openvino._pyopenvino.Output' and 'openvino._pyopenvino.Output'
FAILED keras/src/ops/numpy_test.py::NumpyDtypeTest::test_linspace_[0, 10]_0_float32 - TypeError: unsupported operand type(s) for -: 'openvino._pyopenvino.Output' and 'openvino._pyopenvino.Output'
FAILED keras/src/ops/numpy_test.py::NumpyDtypeTest::test_linspace_[0, 10]_0_float64 - TypeError: unsupported operand type(s) for -: 'openvino._pyopenvino.Output' and 'openvino._pyopenvino.Output'
FAILED keras/src/ops/numpy_test.py::NumpyDtypeTest::test_linspace_[0, 10]_0_none - TypeError: unsupported operand type(s) for -: 'openvino._pyopenvino.Output' and 'openvino._pyopenvino.Output'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Assigned Reviewer
Development

Successfully merging this pull request may close these issues.

None yet

4 participants