-
Notifications
You must be signed in to change notification settings - Fork 124
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
Fix deepcopy of ov.Tensor #1146
Conversation
optimum/intel/openvino/utils.py
Outdated
elif isinstance(inputs, tuple): | ||
new_inputs = tuple(deepcopy_data(elem) for elem in inputs) | ||
elif isinstance(inputs, openvino.Tensor): | ||
new_inputs = openvino.Tensor(np.zeros(inputs.shape, dtype=inputs.element_type.to_dtype())) |
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.
new_inputs = openvino.Tensor(np.zeros(inputs.shape, dtype=inputs.element_type.to_dtype())) | |
new_inputs = openvino.Tensor(np.empty(inputs.shape, dtype=inputs.element_type.to_dtype())) |
optimum/intel/openvino/utils.py
Outdated
elif isinstance(inputs, tuple): | ||
new_inputs = tuple(deepcopy_data(elem) for elem in inputs) | ||
elif isinstance(inputs, openvino.Tensor): | ||
new_inputs = openvino.Tensor(np.zeros(inputs.shape, dtype=inputs.element_type.to_dtype())) |
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.
What will happen if inputs.element_type
is bf16, u4 or i4?
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.
Thanks for the comment!
I added a type
argument to be sure that output tensor has a correct type.
tests/openvino/test_quantization.py
Outdated
"f": [ov.Tensor(np.ones((1, 2, 3))), ov.Tensor(np.ones((1, 2, 3)))], | ||
} | ||
copied_data = deepcopy_data(data) | ||
assert copied_data["a"] is not data["a"] |
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 use self.assertTrue(...)
or similar instead of assert ...
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.
updated
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.
Thanks!
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
The right place for this fix is OpenVINO Python API. If we do it we can fix it in all the integrations of OV to 3rd party projects including Optimum, Ulralytics, etc. |
There is an open ticket to add |
I am still thinking that this is not a good idea to fix OV issues in 3rd party projects. From what I understood you have problems with NNCF CI. To address them quickly, you could:
cc'ed @alexsu52 to drive that |
What does this PR do?
Fix applying deepcopy to ov.Tensor