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

Use OV RTTI for ConversionExtensions #28834

Conversation

ilya-lavrenov
Copy link
Contributor

Details:

  • Use OV RTTI for ConversionExtensions

Tickets:

@ilya-lavrenov ilya-lavrenov added this to the 2025.1 milestone Feb 5, 2025
@ilya-lavrenov ilya-lavrenov requested review from a team as code owners February 5, 2025 12:56
@github-actions github-actions bot added category: inference OpenVINO Runtime library - Inference category: Core OpenVINO Core (aka ngraph) category: build OpenVINO cmake script / infra category: IR FE OpenVINO IR v10 / v11 FrontEnd category: ONNX FE OpenVINO ONNX FrontEnd category: PDPD FE OpenVINO PaddlePaddle FrontEnd category: TF FE OpenVINO TensorFlow FrontEnd category: extensions OpenVINO Extensibility Mechanism for custom operations category: CPP API OpenVINO CPP API bindings category: PyTorch FE OpenVINO PyTorch Frontend category: TFL FE OpenVINO TensorFlow Lite FrontEnd category: JAX FE OpenVINO JAX FrontEnd labels Feb 5, 2025
}
virtual const DiscreteTypeInfo& get_type_info() const {
return get_type_info_static();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@t-jankowski I see that in some places we need to use custom RTTI declaration to ensure it's marked as virtual

Can we expend OPENVINO_RTTI for such cases ? I suppose default OPENVINO_RTTI does not provide virtual? should we have something like OPENVINO_RTTI_BASE_CLASS or similar ? to denote that we later want to override definitions

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, OPENVINO_RTTI_BASE_CLASS would enforce virtual for get_type_info. I'll make it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in #28911

@ilya-lavrenov ilya-lavrenov force-pushed the rtti-for-conversion-extension branch 2 times, most recently from c579de4 to fe9bdc9 Compare February 5, 2025 14:23
Copy link
Member

@rkazants rkazants left a comment

Choose a reason for hiding this comment

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

comment left

@ilya-lavrenov ilya-lavrenov force-pushed the rtti-for-conversion-extension branch 3 times, most recently from 2a80515 to d8cd8b9 Compare February 6, 2025 06:21
@ilya-lavrenov ilya-lavrenov force-pushed the rtti-for-conversion-extension branch from d8cd8b9 to 30a1082 Compare February 6, 2025 06:29
@ilya-lavrenov ilya-lavrenov force-pushed the rtti-for-conversion-extension branch from 30a1082 to 96235f9 Compare February 6, 2025 08:20
@ilya-lavrenov
Copy link
Contributor Author

@olpipi @rkazants @t-jankowski @praasz please, review

# define OPENVINO_DYNAMIC_CAST
return true;
#else
return std::is_base_of_v<ov::frontend::ConversionExtensionBase, T>;
Copy link
Contributor

@olpipi olpipi Feb 7, 2025

Choose a reason for hiding this comment

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

I find it a bit odd that we have common code that depends on some specific details. (as_type_ptr depends on ov::frontend::ConversionExtensionBase).

I'd suggest to add special conversion func for ConversionExtensions into src/frontends/common/include/openvino/frontend/extension/conversion.hpp. And use it from FEs instead of as_type_ptr.
Smth like that:

template <typename Type, typename Value, typename = std::enable_if_t<std::is_base_of_v<ConversionExtensionBase, Type>>>
auto conversion_extension_as_type_ptr(const Value& value) -> decltype(::ov::util::AsTypePtr<Value>::template call<Type>(value)) {
        return ::ov::util::AsTypePtr<Value>::template call<Type>(value);
}

But if everyone else is ok with it, then OK :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with the conclusion. As of solution I'd apply some type traits based on integral_const.

@ilya-lavrenov ilya-lavrenov dismissed rkazants’s stale review February 8, 2025 12:27

No comments anymore

@ilya-lavrenov ilya-lavrenov added this pull request to the merge queue Feb 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 8, 2025
@ilya-lavrenov ilya-lavrenov added this pull request to the merge queue Feb 8, 2025
Merged via the queue into openvinotoolkit:master with commit b5a8d80 Feb 8, 2025
185 checks passed
@ilya-lavrenov ilya-lavrenov deleted the rtti-for-conversion-extension branch February 8, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: build OpenVINO cmake script / infra category: Core OpenVINO Core (aka ngraph) category: CPP API OpenVINO CPP API bindings category: extensions OpenVINO Extensibility Mechanism for custom operations category: inference OpenVINO Runtime library - Inference category: IR FE OpenVINO IR v10 / v11 FrontEnd category: JAX FE OpenVINO JAX FrontEnd category: ONNX FE OpenVINO ONNX FrontEnd category: PDPD FE OpenVINO PaddlePaddle FrontEnd category: PyTorch FE OpenVINO PyTorch Frontend category: TF FE OpenVINO TensorFlow FrontEnd category: TFL FE OpenVINO TensorFlow Lite FrontEnd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants