-
Notifications
You must be signed in to change notification settings - Fork 3k
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 an option in OpenVINOProviderOptions to support the queue-based overload for creating ClContext #19699
base: main
Are you sure you want to change the base?
Conversation
…IOBuffering with OpenVINO.
@microsoft-github-policy-service agree |
/azp run Linux OpenVINO CI Pipeline |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -623,7 +623,8 @@ typedef struct OrtOpenVINOProviderOptions { | |||
cache_dir{}, | |||
context{}, | |||
enable_opencl_throttling{}, | |||
enable_dynamic_shapes{} {} | |||
enable_dynamic_shapes{}, | |||
queue{} {} |
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.
The struct is frozen and its our legacy API. Kindly upgrade to ORT ProviderOptions Map structure
@fireyoshiqc Can you explain on the use case behind OpenCL queue option and its impact over using OpenCL context. |
@preetha-intel // OpenVINO headers:
/**
* @brief Constructs context object from user-supplied OpenCL context handle
* @param core A reference to OpenVINO Runtime Core object
* @param queue An OpenCL queue to be used to create shared remote context. Queue will be reused inside the plugin.
* @note Only latency mode is supported for such context sharing case.
*/
ClContext(Core& core, cl_command_queue queue) {
cl_context ctx;
auto res = clGetCommandQueueInfo(queue, CL_QUEUE_CONTEXT, sizeof(cl_context), &ctx, nullptr);
OPENVINO_ASSERT(res == CL_SUCCESS, "Can't get context from given opencl queue");
AnyMap context_params = {{ov::intel_gpu::context_type.name(), ov::intel_gpu::ContextType::OCL},
{ov::intel_gpu::ocl_context.name(), static_cast<gpu_handle_param>(ctx)},
{ov::intel_gpu::ocl_queue.name(), static_cast<gpu_handle_param>(queue)}};
*this = core.create_context(device_name, context_params).as<ClContext>();
// In our code:
if( inferOnGPU )
{
auto openCvOpenClQueue{ cv::ocl::OpenCLExecutionContext::getCurrent().getQueue() };
// create the context from the current command queue so that OpenVINO can infer Async with correct scheduling.
context = std::make_shared<ov::intel_gpu::ocl::ClContext>( core, static_cast<cl_command_queue>( openCvOpenClQueue.ptr() ) );
} We wanted to migrate to using ONNX Runtime with the OpenVINO EP to standardize our API across different backends. However, this function isn't "available" to use through the Provider options because only a context can be supplied, not a queue. |
Description
Currently, the OpenVINO EP only provides a way to share an OpenCL context (for IO Buffering) through a context pointer, given in its provider options (either the struct or string-map based API).
This is problematic when wanting to use a specific OpenCL queue instead, as there is no way to do so through the current API, even though OpenVINO itself provides an overload for it.
This PR addresses this issue by adding an option to the OpenVINO EP provider options that enables the use of that second overload. This makes it possible to explicitly share OpenCL command queues when using OpenVINO EP.
Motivation and Context
As described in issue #19697.