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

Add preliminary support of OpenVINO as Keras 3 backend #19727

Merged
merged 114 commits into from
Dec 18, 2024

Conversation

rkazants
Copy link
Contributor

@rkazants rkazants commented May 17, 2024

Details: Support OpenVINO as Keras 3 backend. This is inference-only backend. In order to switch on this, define environment variable as follows: os.environ["KERAS_BACKEND"] = "openvino" or use set_backend.

Here is an example how it works:
Install OpenVINO pip install openvino -U

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

# build a simple network
x1 = keras.Input(shape=(2,), dtype='float32')
x2 = keras.Input(shape=(2,), dtype='float32')
add = keras.layers.Add()([x1, x2])
sigmoid = keras.activations.sigmoid(add)
model = keras.Model(inputs={'x1': x1, 'x2': x2}, outputs={'sigmoid': sigmoid})
model.summary()

# infer using OpenVINO
out = model.predict({'x1': np.array([[1.0, 2.0]], dtype=np.float32),
                     'x2': np.array([[3.0, 4.0]], dtype=np.float32)})
print('openvino out = ', out)

Added support for operations that allow to infer mobilenet_v3_small and bert_base_en_uncased from Keras Hub.

Example 1:

# from here https://keras.io/api/keras_nlp/models/bert/bert_text_classifier/#from_preset-method
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),
}

# Pretrained classifier without preprocessing.
#classifier = keras_hub.models.BertTextClassifier.from_preset(
#    "bert_base_en_uncased",
#    num_classes=4,
#    preprocessor=None,
#)
#keras.saving.save_model(classifier, "bert_base_en_uncased.keras")
classifier = keras.saving.load_model("bert_base_en_uncased.keras")
#output = classifier.predict(x=features, batch_size=2)
output = classifier.predict(features)

Example 2:

# from here https://keras.io/api/keras_cv/models/backbones/mobilenet_v3/
import os

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

rng = np.random.default_rng(23345243)

#input_data = np.random.rand(8, 224, 224, 3)
input_data = rng.uniform(0.0, 1.0, [8, 224, 224, 3]).astype(np.float32)
model = keras.saving.load_model("mobilenet_v3_small.keras")
#model = keras_cv.models.MobileNetV3Backbone.from_preset("mobilenet_v3_small",)

output = model.predict(input_data)

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
Copy link

google-cla bot commented May 17, 2024

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.

Copy link
Collaborator

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

keras/src/ops/function.py Outdated Show resolved Hide resolved
keras/src/layers/layer.py Outdated Show resolved Hide resolved
keras/src/backend/openvino/linalg.py Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented May 20, 2024

Codecov Report

Attention: Patch coverage is 60.14735% with 595 lines in your changes missing coverage. Please review.

Project coverage is 81.87%. Comparing base (4c05e0c) to head (74778b1).

Files with missing lines Patch % Lines
keras/src/backend/openvino/numpy.py 53.71% 254 Missing and 20 partials ⚠️
keras/src/backend/openvino/core.py 59.40% 126 Missing and 23 partials ⚠️
keras/src/backend/openvino/trainer.py 27.00% 100 Missing ⚠️
keras/src/backend/openvino/nn.py 77.25% 49 Missing and 4 partials ⚠️
keras/src/backend/openvino/math.py 82.97% 6 Missing and 2 partials ⚠️
keras/src/backend/openvino/random.py 94.11% 1 Missing and 2 partials ⚠️
keras/src/utils/backend_utils.py 25.00% 3 Missing ⚠️
keras/src/backend/__init__.py 75.00% 0 Missing and 1 partial ⚠️
keras/src/backend/openvino/rnn.py 85.71% 1 Missing ⚠️
keras/src/export/export_lib.py 50.00% 0 Missing and 1 partial ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19727      +/-   ##
==========================================
- Coverage   82.53%   81.87%   -0.66%     
==========================================
  Files         530      542      +12     
  Lines       49058    50550    +1492     
  Branches     7627     7809     +182     
==========================================
+ Hits        40489    41390     +901     
- Misses       6731     7271     +540     
- Partials     1838     1889      +51     
Flag Coverage Δ
keras 81.71% <60.14%> (-0.66%) ⬇️
keras-jax 63.78% <0.06%> (-1.95%) ⬇️
keras-numpy 58.82% <0.13%> (-1.79%) ⬇️
keras-openvino 29.98% <60.01%> (?)
keras-tensorflow 64.54% <0.06%> (-1.97%) ⬇️
keras-torch 63.61% <0.06%> (-1.94%) ⬇️

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.

@gbaned
Copy link
Collaborator

gbaned commented Jun 14, 2024

Hi @rkazants Can you please resolve the conflicts? Thank you!

@rkazants
Copy link
Contributor Author

Hi @rkazants Can you please resolve the conflicts? Thank you!

I am working on this PR. I am trying to resolve comments.

Best regards,
Roman

@gbaned
Copy link
Collaborator

gbaned commented Jul 12, 2024

Hi @rkazants Any update on this PR? Please. Thank you!

Copy link

This PR is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Jul 27, 2024
@rkazants
Copy link
Contributor Author

I am just back from vacation. I plan to continue from the next week.

Copy link

This PR is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

@gbaned
Copy link
Collaborator

gbaned commented Sep 9, 2024

Hi @rkazants Any update on this PR? Please. Thank you!

@rkazants
Copy link
Contributor Author

rkazants commented Sep 9, 2024

Hi @rkazants Any update on this PR? Please. Thank you!

Hi @gbaned, please anticipate the update early this week. Sorry for the delay.

Thanks,
Roman

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
@rkazants
Copy link
Contributor Author

rkazants commented Dec 14, 2024

Thanks Roman! Is there any way to try this without the hardware?

Jeff,
sure, you can try this out on your laptop with x86, ARM CPU (Win, Linux, MacOS) or Intel GPU, NPU hardware? Just install OpenVINO by pip install -U openvino. See some examples in PR description.

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
@rkazants rkazants requested a review from jeffcarp December 14, 2024 19:57
Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
@rkazants
Copy link
Contributor Author

Hi @fchollet, @jeffcarp, all comments were resolved so far. Please let me know what else is needed for merging this PR.

Thanks a lot,
Roman

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
Copy link
Member

@jeffcarp jeffcarp left a comment

Choose a reason for hiding this comment

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

Thanks Roman! LGTM from my side. Please also get an LGTM from Francois before proceeding.

keras/src/backend/openvino/trainer.py Show resolved Hide resolved
@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Dec 16, 2024
@jeffcarp
Copy link
Member

sure, you can try this out on your laptop with x86

Thanks! I was able to confirm running this branch locally.

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
@google-ml-butler google-ml-butler bot removed the ready to pull Ready to be merged into the codebase label Dec 17, 2024
@rkazants rkazants requested a review from fchollet December 17, 2024 08:16
@rkazants
Copy link
Contributor Author

@fchollet, all is done. Please review it again.

Thank you very much,
Roman

Copy link
Collaborator

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

LGTM -- thank you for the contribution! 👍

Should we expect an announcement from Intel here? How should we communicate this to the developer community?

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Dec 17, 2024
@fchollet fchollet merged commit bce0f5b into keras-team:master Dec 18, 2024
9 of 10 checks passed
@google-ml-butler google-ml-butler bot removed awaiting review ready to pull Ready to be merged into the codebase labels Dec 18, 2024
@rkazants
Copy link
Contributor Author

rkazants commented Dec 19, 2024

LGTM -- thank you for the contribution! 👍

Should we expect an announcement from Intel here? How should we communicate this to the developer community?

Hi François (fchollet),

Really thanks for your big help in reviewing this PR.
From OpenVINO side, so plan to announce about this feature in the upcoming OpenVINO 2025.0 release in January. It will be declared as experimental feature. We will add this into OpenVINO release notes and add into documentation "how to deploy Keras 3 models using OpenVINO" (https://docs.openvino.ai/2024/openvino-workflow.html), add OpenVINO notebook to showcase Keras 3 + OpenVINO. Once we reach close parity with NumPy backend in terms of operation coverage and reach quite the same test passrate, we will remove "experimental". I will also make a post in LinkedIn and our Discord to invite open-source community to contribute to this very soon.

From Keras side, I will update Keras documentation as well and declare it as experimental feature. Please let me know how to proceed with Keras documentation. Also, can you add this into Keras release notes of the upcoming Keras release from master? Please let me know what will be Keras release number from master that will include this changes? And when release is planned?

Best regards,
Roman

@fchollet
Copy link
Collaborator

We will include the new backend in the release notes for the next release. Please feel free to propose edits to the docs website via a PR to keras-team/keras-io!

shashaka pushed a commit to shashaka/keras that referenced this pull request Dec 20, 2024
)

* [POC][OV] Support OpenVINO as Keras 3 backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Mark all unsupported ops from numpy space

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Mark unsupported ops in core, image, and linalg spaces

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Mark unsupported ops in math, nn, random, and rnn spaces

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix sorting imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Format imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix sorting imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix sorting imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix inference

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Remove openvino specific code in common part

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix typo

* Clean-up code

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Recover imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Sort imports properly

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Format source code

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Format the rest of source code

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Continue format adjustment

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add OpenVINO dependency

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix inference using OV backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Support bert_base_en_uncased and mobilenet_v3_small from Keras Hub

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Remove extra openvino specific code from layer.py

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Apply code-style formatting

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Apply code-style formatting

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix remained code-style issue

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Run tests for OpenVINO backend in GHA

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add config file for openvino backend validation

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add import test for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix error in import_test.py

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add import_test for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add openvino specific integration tests in GHA

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Exclude coverage for OpenVINO

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* remove coverage for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Try layer tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Run layer tests for openvino backend selectively

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Mark enabled tests for openvino backend in a different way

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Update .github/workflows/actions.yml

* Fix import for BackendVariable

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix errors in layer tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add test for Elu via openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix sorted imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Extend testing for attention

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Update keras/src/layers/attention/attention_test.py

* Switch on activation tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on attention tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Update keras/src/layers/attention/additive_attention_test.py

* Update keras/src/layers/attention/grouped_query_attention_test.py

* Run conv tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix convolution in openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Work around constant creation for tuple

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Work around constant creation in reshape

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Run depthwise conv tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix get_ov_output for other x types

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix elu translation

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix softmax and log_softmax for None axis

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Run nn tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix numpy operations for axis to be None

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Run operation_test for openvino_backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on math_test for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on image tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on linalg test for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Extend OpenVINOKerasTensor with new built-in methods and fix shape op

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on core tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Use different way of OpenVINO model creation that supports call method

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Unify integration test for openvino

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Support new operations abs, mod, etc.

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add support for more operations like squeeze, max

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Try to use excluded test files list

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Apply formatting for normalization_test.py

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Correct GHA yml file

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Test that openvino backend is used

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Revert testing change in excluded test files list

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Include testing group

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Include legacy test group

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Exclude legacy group of tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Include initializers tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Skip tests for initializers group

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Remove export test group from ignore

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Include dtype_policies test group

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Reduce ignored tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix ops.cast

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add decorator for custom_gradient

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Shorten line in custom_gradient

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Ignore dtype_policy_map test

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Include callback tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on backend tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Exclude failing tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Correct paths to excluded tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on some layers tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Remove pytest.mark.openvino_backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Register mark requires_trainable_backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Ignore test files in a different way

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Try different way to ignore test files

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix GHA yml

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Support tuple axis for logsumexp

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on some ops tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on some callbacks tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add openvino export

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Update sklearn tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add a comment to skipp numerical_test

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add custom requirements file for OpenVINO

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add reqs of openvino installation for api changes check

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix types of Variables and switch on some variables tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix nightly code check

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

---------

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
fchollet pushed a commit that referenced this pull request Dec 22, 2024
* Add implementations for random_saturation

* change parse_factor method to inner method.

* Add implementations for random_color_jitter

* Fix Randomhue (#20652)

* Small fix in random hue

* use self.backend for seed

* test: add test for class weights (py_dataset adapter) (#20638)

* test: add test for class weights (py_dataset adapter)

* "call _standardize_batch from enqueuer"

m

* add more tests, handle pytorch astype issue

m

* convert to numpy to ensure consistent handling of operations

* Fix paths for pytest in contribution guide (#20655)

* Add preliminary support of OpenVINO as Keras 3 backend (#19727)

* [POC][OV] Support OpenVINO as Keras 3 backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Mark all unsupported ops from numpy space

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Mark unsupported ops in core, image, and linalg spaces

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Mark unsupported ops in math, nn, random, and rnn spaces

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix sorting imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Format imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix sorting imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix sorting imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix inference

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Remove openvino specific code in common part

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix typo

* Clean-up code

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Recover imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Sort imports properly

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Format source code

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Format the rest of source code

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Continue format adjustment

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add OpenVINO dependency

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix inference using OV backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Support bert_base_en_uncased and mobilenet_v3_small from Keras Hub

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Remove extra openvino specific code from layer.py

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Apply code-style formatting

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Apply code-style formatting

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix remained code-style issue

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Run tests for OpenVINO backend in GHA

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add config file for openvino backend validation

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add import test for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix error in import_test.py

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add import_test for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add openvino specific integration tests in GHA

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Exclude coverage for OpenVINO

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* remove coverage for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Try layer tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Run layer tests for openvino backend selectively

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Mark enabled tests for openvino backend in a different way

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Update .github/workflows/actions.yml

* Fix import for BackendVariable

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix errors in layer tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add test for Elu via openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix sorted imports

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Extend testing for attention

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Update keras/src/layers/attention/attention_test.py

* Switch on activation tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on attention tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Update keras/src/layers/attention/additive_attention_test.py

* Update keras/src/layers/attention/grouped_query_attention_test.py

* Run conv tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix convolution in openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Work around constant creation for tuple

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Work around constant creation in reshape

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Run depthwise conv tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix get_ov_output for other x types

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix elu translation

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix softmax and log_softmax for None axis

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Run nn tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix numpy operations for axis to be None

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Run operation_test for openvino_backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on math_test for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on image tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on linalg test for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Extend OpenVINOKerasTensor with new built-in methods and fix shape op

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on core tests for openvino backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Use different way of OpenVINO model creation that supports call method

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Unify integration test for openvino

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Support new operations abs, mod, etc.

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add support for more operations like squeeze, max

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Try to use excluded test files list

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Apply formatting for normalization_test.py

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Correct GHA yml file

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Test that openvino backend is used

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Revert testing change in excluded test files list

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Include testing group

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Include legacy test group

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Exclude legacy group of tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Include initializers tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Skip tests for initializers group

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Remove export test group from ignore

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Include dtype_policies test group

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Reduce ignored tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix ops.cast

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add decorator for custom_gradient

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Shorten line in custom_gradient

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Ignore dtype_policy_map test

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Include callback tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on backend tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Exclude failing tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Correct paths to excluded tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on some layers tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Remove pytest.mark.openvino_backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Register mark requires_trainable_backend

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Ignore test files in a different way

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Try different way to ignore test files

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix GHA yml

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Support tuple axis for logsumexp

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on some ops tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Switch on some callbacks tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add openvino export

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Update sklearn tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add a comment to skipp numerical_test

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add custom requirements file for OpenVINO

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Add reqs of openvino installation for api changes check

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix types of Variables and switch on some variables tests

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Fix nightly code check

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

---------

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>

* Make sklearn dependency optional (#20657)

* Add a condition to verify training status during image processing (#20650)

* Add a condition to verify training status during image processing

* resolve merge conflict

* fix transform_bounding_boxes logic

* add transform_bounding_boxes test

* Fix recurrent dropout for GRU. (#20656)

The simplified implementation, which used the same recurrent dropout masks for all the previous states didn't work and caused the training to not converge with large enough recurrent dropout values.

This new implementation is now the same as Keras 2. Note that recurrent dropout requires "implementation 1" to be turned on.

Fixes #20276

* Fix example title in probabilistic_metrics.py (#20662)

* Change recurrent dropout implementation for LSTM. (#20663)

This change is to make the implementation of recurrent dropout consistent with GRU (changed as of #20656 ) and Keras 2.

Also fixed a bug where the GRU fix would break when using CUDNN with a dropout and no recurrent dropout. The solution is to create multiple masks only when needed (implementation == 1).

Added coverage for the case when dropout is set and recurrent dropout is not set.

* Never pass enable_xla=False or native_serialization=False in tests (#20664)

These are invalid options in the latest version of jax2tf, they
will just immediately throw.

* Fix `PyDatasetAdapterTest::test_class_weight` test with Torch on GPU. (#20665)

The test was failing because arrays on device and on cpu were compared.

* Fix up torch GPU failing test for mix up (#20666)

We need to make sure to use get any tensors places on cpu before using
them in the tensorflow backend during preprocessing.

* Add random_color_jitter processing layer

* Add random_color_jitter test

* Update test cases

* Correct failed test case

* Correct failed test case

* Correct failed test case

---------

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
Co-authored-by: IMvision12 <88665786+IMvision12@users.noreply.github.com>
Co-authored-by: Enrico <e.durso@live.com>
Co-authored-by: Marco <mmicu.github00@gmail.com>
Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com>
Co-authored-by: Matt Watson <1389937+mattdangerw@users.noreply.github.com>
Co-authored-by: hertschuh <1091026+hertschuh@users.noreply.github.com>
Co-authored-by: Jasmine Dhantule <dhantule@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

7 participants