Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Binary file not shown.
Empty file.
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
env =
KERAS_BACKEND=openvino
Empty file added src/__init__.py
Empty file.
Binary file added src/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Empty file added src/ops/__init__.py
Empty file.
Binary file added src/ops/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
23 changes: 23 additions & 0 deletions src/ops/decompositions/openvino/numpy_ops.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# src/ops/decompositions/openvino/numpy_ops.py

from openvino import op as ops, Core, Type
import numpy as np

core = Core()
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The imports ops, Core, and Type from openvino are unused in this file, as is the core variable. They should be removed to improve code clarity and maintainability.

Suggested change
from openvino import op as ops, Core, Type
import numpy as np
core = Core()
import numpy as np


# logspace function that returns a numpy array using OpenVINO nodes
def logspace(start, stop, num=50, dtype=np.float32):
# Using numpy for simplicity to generate values
values = np.logspace(start, stop, num=num, dtype=dtype)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The implementation of logspace uses numpy.logspace directly, but the comment on line 8 states it should use OpenVINO nodes. This is misleading and doesn't align with the purpose of an OpenVINO decomposition module.1 This function should be implemented using OpenVINO operations. If this is a temporary placeholder, please add a TODO comment and clarify that it's not a final implementation.

Suggested change
# Using numpy for simplicity to generate values
values = np.logspace(start, stop, num=num, dtype=dtype)
# TODO: Implement with OpenVINO operations instead of numpy.
# Using numpy for simplicity to generate values for now.
values = np.logspace(start, stop, num=num, dtype=dtype)

Style Guide References

Footnotes

  1. Documentation is an integral part of the API and should be accurate to ensure a good developer experience.

return values

# Dummy evaluate function (since OpenVINO nodes require model compilation)
def evaluate(node):
# If node is already a numpy array, just return it
return node
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The evaluate function is currently a dummy identity function. While the comment explains why, the function name is misleading.1 Consider renaming it to something like _dummy_evaluate to make it clear that it's a placeholder and not a real evaluation function. This will also require updating its usage in src/ops/numpy_test.py. Also, adding a TODO to track the implementation of the actual evaluation logic would be beneficial.

Suggested change
def evaluate(node):
# If node is already a numpy array, just return it
return node
def _dummy_evaluate(node):
# TODO: Implement a real evaluation function for OpenVINO graphs.
# If node is already a numpy array, just return it
return node

Style Guide References

Footnotes

  1. The meaning of an argument or function should be clear from its name and should not require knowledge that only the implementers have. Naming should be intuitive and easy to remember.







17 changes: 17 additions & 0 deletions src/ops/numpy_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# src/ops/numpy_test.py

import numpy as np
from decompositions.openvino.numpy_ops import logspace, evaluate

def test_logspace_basic():
node = logspace(0, 2, num=3, dtype=np.float32)
result = evaluate(node)
expected = np.array([1.0, 10.0, 100.0], dtype=np.float32)
assert np.allclose(result, expected), f"Expected {expected}, got {result}"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This test currently verifies the behavior of numpy.logspace because the logspace and evaluate functions in numpy_ops.py are simple wrappers around numpy and an identity function, respectively. Once logspace is implemented with actual OpenVINO operations, this test will need to be updated to properly validate the OpenVINO-specific logic. As it stands, it doesn't provide coverage for the OpenVINO backend decomposition.


if __name__ == "__main__":
import pytest
pytest.main([__file__, "-v"])



Empty file.
Loading