-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[Py OV] Alias classes and functions in flatten openvino namespace #28085
[Py OV] Alias classes and functions in flatten openvino namespace #28085
Conversation
Signed-off-by: Alicja Miloszewska <[email protected]>
…into almilosz/alias-classes Signed-off-by: Alicja Miloszewska <[email protected]>
Signed-off-by: Alicja Miloszewska <[email protected]>
Signed-off-by: Alicja Miloszewska <[email protected]>
…into almilosz/alias-classes Signed-off-by: Alicja Miloszewska <[email protected]>
Signed-off-by: Alicja Miloszewska <[email protected]>
Signed-off-by: Alicja Miloszewska <[email protected]>
tools/ovc/openvino/__init__.py
Outdated
# Extend Node class to support binary operators | ||
Node.__add__ = opset13.add | ||
Node.__sub__ = opset13.subtract | ||
Node.__mul__ = opset13.multiply | ||
Node.__div__ = opset13.divide | ||
Node.__truediv__ = opset13.divide | ||
Node.__radd__ = lambda left, right: opset13.add(right, left) | ||
Node.__rsub__ = lambda left, right: opset13.subtract(right, left) | ||
Node.__rmul__ = lambda left, right: opset13.multiply(right, left) | ||
Node.__rdiv__ = lambda left, right: opset13.divide(right, left) | ||
Node.__rtruediv__ = lambda left, right: opset13.divide(right, left) | ||
Node.__eq__ = utils.deprecated(version="2025.3", message="Use ops.equal instead")(opset13.equal) | ||
Node.__ne__ = utils.deprecated(version="2025.3", message="Use ops.not_equal instead")(opset13.not_equal) | ||
Node.__lt__ = utils.deprecated(version="2025.3", message="Use ops.less instead")(opset13.less) | ||
Node.__le__ = utils.deprecated(version="2025.3", message="Use ops.less_equal instead")(opset13.less_equal) | ||
Node.__gt__ = utils.deprecated(version="2025.3", message="Use ops.greater instead")(opset13.greater) | ||
Node.__ge__ = utils.deprecated(version="2025.3", message="Use ops.greater_equal instead")(opset13.greater_equal) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need it here. You can extend it in one place and re-use it overall.
Let say in py file for Node class that is more logical to have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fully agree with your comment. I created a task to improve this.
This PR is simply about moving functionality from openvino/runtime/__init__
to openvino/__init__
so let's discuss it as a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us do in this PR. It is normal process to get feedback and apply it in right away. Moreover, it is slight change and not a big deal:)
Signed-off-by: Alicja Miloszewska <[email protected]>
…into almilosz/alias-classes Signed-off-by: Alicja Miloszewska <[email protected]>
Signed-off-by: Alicja Miloszewska <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove duplicating code with defining Node class methods.
Yan can simple define it in Node py file (that is logical) and use it overall
I agree with you, but I don't want to introduce any new logic or new namespace in this PR. Let's discuss it separately. I created a task to not forget about it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one concerning thing is the specific opset13
imports in the main __init__.py
file, but in my opinion it's out of scope of this PR.
Node.__add__ = opset13.add | ||
Node.__sub__ = opset13.subtract | ||
Node.__mul__ = opset13.multiply | ||
Node.__div__ = opset13.divide | ||
Node.__truediv__ = opset13.divide | ||
Node.__radd__ = lambda left, right: opset13.add(right, left) | ||
Node.__rsub__ = lambda left, right: opset13.subtract(right, left) | ||
Node.__rmul__ = lambda left, right: opset13.multiply(right, left) | ||
Node.__rdiv__ = lambda left, right: opset13.divide(right, left) | ||
Node.__rtruediv__ = lambda left, right: opset13.divide(right, left) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have opset13
here specifically? I'm not blocking the PR, it's a separate discussion.
There's no mechanism to get the "newest opset" op (which I think would be a good addition to the API), but still, there has to be room for improvement here. We may introduce a new version for one of these ops, for any reason, it's an edge case to remember that it also should be bumped here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moreover, these arithmetic methods are semantically incorrect to have. That is because we can't sum up nodes that have more one outputs.
It is more logical to define such methods for ov::Output (corresponding to tensors).
I don't think this is a right approach to create task for review comments that can be applied easily by extra commit. Let us do this in this PR because the task can be forgotten, postponed for long time and closed finally as not implemented. Moreover, in that logic you have weak spot using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still not convinced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I give the green light with one condition: let's rollback changes for Node magic methods
and move them from __init__
in a separate PR.
This PR blocks #27694, but magic methods
IMHO doesn't, so they can be moved after holidays.
Signed-off-by: Alicja Miloszewska <[email protected]>
d0a8a39
…envinotoolkit#28085) ### Details: - Add imports from _pyopenivno on the top of the openvino `__init__.py` - Move `Node` binary operators support at the bottom of openvino `__init__.py` Classes and functions available in `openvino/runtime` will match those in flatten `openvino` ### Tickets: - [CVS-129453](https://jira.devtools.intel.com/browse/CVS-129453) --------- Signed-off-by: Alicja Miloszewska <[email protected]> Co-authored-by: Michal Lukaszewski <[email protected]>
…pace (openvinotoolkit#28085)" This reverts commit d0a8a39.
### Details: Add deprecation warning for `openvino.runtime` that will be shown **ONCE** when sb will access runtime functionality for the first time. Examples: ![Screenshot 2025-01-10 114701](https://github.com/user-attachments/assets/4229ede3-3b86-418a-8dbf-f230ff91983b) ![warn_updated](https://github.com/user-attachments/assets/4b4a7c56-c5ca-4b7b-8b34-f89f3a4bc627) `openvino.runtime` funtionality was added to openvino namespace in these PRs: - #27785 - #27902 - #28007 - #28062 - #28085 Internal calls in `openvino` module also triggered warning, so they were updated: - #28166 - #28356 ### Tickets: - [CVS-129451](https://jira.devtools.intel.com/browse/CVS-129451) --------- Signed-off-by: Alicja Miloszewska <[email protected]> Co-authored-by: Anastasia Kuporosova <[email protected]>
### Reverted: - openvinotoolkit#28062 (Guilty one) - openvinotoolkit#28085 (Relies on Guilty one) - openvinotoolkit#28166 (Relies on Guilty one)
…7694) ### Details: Add deprecation warning for `openvino.runtime` that will be shown **ONCE** when sb will access runtime functionality for the first time. Examples: ![Screenshot 2025-01-10 114701](https://github.com/user-attachments/assets/4229ede3-3b86-418a-8dbf-f230ff91983b) ![warn_updated](https://github.com/user-attachments/assets/4b4a7c56-c5ca-4b7b-8b34-f89f3a4bc627) `openvino.runtime` funtionality was added to openvino namespace in these PRs: - openvinotoolkit#27785 - openvinotoolkit#27902 - openvinotoolkit#28007 - openvinotoolkit#28062 - openvinotoolkit#28085 Internal calls in `openvino` module also triggered warning, so they were updated: - openvinotoolkit#28166 - openvinotoolkit#28356 ### Tickets: - [CVS-129451](https://jira.devtools.intel.com/browse/CVS-129451) --------- Signed-off-by: Alicja Miloszewska <[email protected]> Co-authored-by: Anastasia Kuporosova <[email protected]>
Details:
__init__.py
Node
binary operators support at the bottom of openvino__init__.py
Classes and functions available in
openvino/runtime
will match those in flattenopenvino
Tickets: