Skip to content

[Good First Issue][Keras 3 OpenVINO Backend]: Support numpy.diagonal operation #29116

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
rkazants opened this issue Feb 22, 2025 · 20 comments · May be fixed by keras-team/keras#21156
Open

[Good First Issue][Keras 3 OpenVINO Backend]: Support numpy.diagonal operation #29116

rkazants opened this issue Feb 22, 2025 · 20 comments · May be fixed by keras-team/keras#21156
Assignees
Labels
good first issue Good for newcomers Keras 3 OpenVINO Backend Keras 3 OpenVINO Backend no_stale Do not mark as stale

Comments

@rkazants
Copy link
Member

Context

🚀**A great opportunity to contribute to two popular AI projects with just one PR:: Keras 3 and OpenVINO.**🚀

Keras 3 enables seamless switching between supported backends—PyTorch, TensorFlow, and JAX—for both training and inference of traditional models and LLMs/GenAI pipelines. Since Keras 3.8.0, we've introduced a preview version of the OpenVINO backend (for inference only), allowing developers to leverage OpenVINO for model predictions directly within Keras 3 workflows. Activating the OpenVINO backend requires just one line of code to run inference on Keras 3-trained models. Here’s an example for a BERT model from Keras Hub:

import os
os.environ["KERAS_BACKEND"] = "openvino"
import numpy as np
import keras
import keras_hub

features = {
    "token_ids": np.ones(shape=(2, 12), dtype="int32"),
    "segment_ids": np.array([[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0]] * 2),
    "padding_mask": np.array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]] * 2),
}

classifier = keras_hub.models.BertTextClassifier.from_preset("bert_base_en_uncased", num_classes=4, preprocessor=None)
output = classifier.predict(features)

Currently, the OpenVINO backend lacks support for some operations. Our goal is to resolve this gap and to optimize it for inference on Intel devices—including CPUs, integrated GPUs, discrete GPUs, and NPUs—by supporting as many models as possible while delivering optimal performance. We aim to make the OpenVINO backend the No. 1 choice for model inference within the Keras 3 workflow.

What needs to be done?

Steps to Contribute

  1. Set up your developer environment:
  • fork and clone keras repo
  • install requirements for OpenVINO backend development pip install -r requirements-openvino.txt. The requirements file can be found in the root directory of cloned repository
  1. Provide decomposition in Python for numpy.diagonal using OpenVINO opset

  2. Include tests by removing line corresponding to the implemented operation in excluded_concrete_tests.txt file.

  3. Make sure that tests are passing

  • create pytest.ini file and place it in the root directory of the clone repository. This file should contain the following content:
[pytest]
env =
    KERAS_BACKEND=openvino
  • run tests pytest-c ./pytest.ini ./keras/src/ops/numpy_test.py
  1. Commit your changes and create PR in keras repository. Mention @rkazants in PR description for review.

Below is an exemplar PR of how support for numpy.amax has been implemented.

Example Pull Requests

Resources

Contact points

@rkazants

Ticket

No response

@geeky33
Copy link
Contributor

geeky33 commented Feb 22, 2025

.take

Copy link
Contributor

Thank you for looking into this issue! Please let us know if you have any questions or require any help.

@mlukasze mlukasze moved this from Contributors Needed to Assigned in Good first issues Feb 24, 2025
@faizan102418
Copy link

.take

Copy link
Contributor

Thanks for being interested in this issue. It looks like this ticket is already assigned to a contributor. Please communicate with the assigned contributor to confirm the status of the issue.

@p-wysocki
Copy link
Contributor

Hello @faizan102418, do you have any questions or require any help?

@faizan102418
Copy link

@p-wysocki Can you provide more details about the expected implementation of numpy.diagonal using OpenVINO opset?

@chiruu12
Copy link

chiruu12 commented Mar 6, 2025

@geeky33 Hey!! please let us know if you are still working on it and I saw you have taken 2 issues but not working on even one of them...

@faizan102418
Copy link

@geeky33 Hey!! please let us know if you are still working on it and I saw you have taken 2 issues but not working on even one of them...

I have made a pull request now

@geeky33
Copy link
Contributor

geeky33 commented Mar 6, 2025

Sir, My university exams were around the corner which is ending tomorrow
Please consider the request
will be submitting the PR by this weekend itself

Extremely sorry for the delay.

@Riddhikshah21
Copy link

.take

Copy link
Contributor

Thanks for being interested in this issue. It looks like this ticket is already assigned to a contributor. Please communicate with the assigned contributor to confirm the status of the issue.

@p-wysocki
Copy link
Contributor

Hello @Riddhikshah21, do you require any help?

@chiruu12
Copy link

@geeky33 Hey! I saw your PR and I think u haven't gone through the rules and how we are supposed to submit our PR please take on issue at a time too! You have been working on this issue for a month... and still your PR's are not in order... please let others contribute if you are not serious about it!
Thanks

@geeky33
Copy link
Contributor

geeky33 commented Mar 25, 2025

Hey @chiruu12

I appreciate the concern, but I’ve followed the rules and taken the time to ensure quality. If there’s a specific issue, I’m happy to address it. Let’s keep the focus on contributions, not assumptions.

Thanks!

@chiruu12
Copy link

Hey @chiruu12

I appreciate the concern, but I’ve followed the rules and taken the time to ensure quality. If there’s a specific issue, I’m happy to address it. Let’s keep the focus on contributions, not assumptions.

Thanks!

Actually I'm not assuming anything here...its just the instructions were really clear about what changes we have to make but u didn't make those changes and at the same time took two issues which are still not resolved after 1 month...

@p-wysocki
Copy link
Contributor

Reopening the issue due to inactivity.

@p-wysocki p-wysocki moved this from Assigned to Contributors Needed in Good first issues Apr 4, 2025
@chiruu12
Copy link

chiruu12 commented Apr 4, 2025

.take

Copy link
Contributor

github-actions bot commented Apr 4, 2025

Thank you for looking into this issue! Please let us know if you have any questions or require any help.

@p-wysocki p-wysocki moved this from Contributors Needed to Assigned in Good first issues Apr 4, 2025
@p-wysocki
Copy link
Contributor

Hello @chiruu12, are you still working on that task?

@chiruu12
Copy link

@p-wysocki Yes sir, just added a PR a few minutes ago.

@mlukasze mlukasze moved this from Assigned to In Review in Good first issues May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Keras 3 OpenVINO Backend Keras 3 OpenVINO Backend no_stale Do not mark as stale
Projects
Status: In Review
6 participants