mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #24068 from TolyaTalamanov:at/add-onnx-coreml-execution-provider
G-API: Support CoreML Execution Providers for ONNXRT Backend #24068 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [ ] I agree to contribute to the project under Apache 2 License. - [ ] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
committed by
GitHub
parent
14688e95ea
commit
9a47e1764a
@@ -39,6 +39,9 @@ public:
|
||||
GAPI_WRAP
|
||||
PyParams& cfgAddExecutionProvider(ep::DirectML ep);
|
||||
|
||||
GAPI_WRAP
|
||||
PyParams& cfgAddExecutionProvider(ep::CoreML ep);
|
||||
|
||||
GAPI_WRAP
|
||||
PyParams& cfgAddExecutionProvider(ep::CUDA ep);
|
||||
|
||||
|
||||
@@ -32,6 +32,65 @@ namespace onnx {
|
||||
*/
|
||||
namespace ep {
|
||||
|
||||
/**
|
||||
* @brief This structure provides functions
|
||||
* that fill inference options for ONNX CoreML Execution Provider.
|
||||
* Please follow https://onnxruntime.ai/docs/execution-providers/CoreML-ExecutionProvider.html#coreml-execution-provider
|
||||
*/
|
||||
struct GAPI_EXPORTS_W_SIMPLE CoreML {
|
||||
/** @brief Class constructor.
|
||||
|
||||
Constructs CoreML parameters.
|
||||
|
||||
*/
|
||||
GAPI_WRAP
|
||||
CoreML() = default;
|
||||
|
||||
/** @brief Limit CoreML Execution Provider to run on CPU only.
|
||||
|
||||
This function is used to limit CoreML to run on CPU only.
|
||||
Please follow: https://onnxruntime.ai/docs/execution-providers/CoreML-ExecutionProvider.html#coreml_flag_use_cpu_only
|
||||
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
GAPI_WRAP
|
||||
CoreML& cfgUseCPUOnly() {
|
||||
use_cpu_only = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Enable CoreML EP to run on a subgraph in the body of a control flow ONNX operator (i.e. a Loop, Scan or If operator).
|
||||
|
||||
This function is used to enable CoreML EP to run on
|
||||
a subgraph of a control flow of ONNX operation.
|
||||
Please follow: https://onnxruntime.ai/docs/execution-providers/CoreML-ExecutionProvider.html#coreml_flag_enable_on_subgraph
|
||||
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
GAPI_WRAP
|
||||
CoreML& cfgEnableOnSubgraph() {
|
||||
enable_on_subgraph = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Enable CoreML EP to run only on Apple Neural Engine.
|
||||
|
||||
This function is used to enable CoreML EP to run only on Apple Neural Engine.
|
||||
Please follow: https://onnxruntime.ai/docs/execution-providers/CoreML-ExecutionProvider.html#coreml_flag_only_enable_device_with_ane
|
||||
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
GAPI_WRAP
|
||||
CoreML& cfgEnableOnlyNeuralEngine() {
|
||||
enable_only_ane = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool use_cpu_only = false;
|
||||
bool enable_on_subgraph = false;
|
||||
bool enable_only_ane = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure provides functions
|
||||
* that fill inference options for CUDA Execution Provider.
|
||||
@@ -205,6 +264,7 @@ public:
|
||||
using EP = cv::util::variant< cv::util::monostate
|
||||
, OpenVINO
|
||||
, DirectML
|
||||
, CoreML
|
||||
, CUDA
|
||||
, TensorRT>;
|
||||
|
||||
@@ -496,6 +556,20 @@ public:
|
||||
|
||||
/** @brief Adds execution provider for runtime.
|
||||
|
||||
The function is used to add ONNX Runtime CoreML Execution Provider options.
|
||||
|
||||
@param ep CoreML Execution Provider options.
|
||||
@see cv::gapi::onnx::ep::CoreML.
|
||||
|
||||
@return the reference on modified object.
|
||||
*/
|
||||
Params<Net>& cfgAddExecutionProvider(ep::CoreML&& ep) {
|
||||
desc.execution_providers.emplace_back(std::move(ep));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Adds execution provider for runtime.
|
||||
|
||||
The function is used to add ONNX Runtime CUDA Execution Provider options.
|
||||
|
||||
@param ep CUDA Execution Provider options.
|
||||
@@ -582,6 +656,11 @@ public:
|
||||
desc.execution_providers.emplace_back(std::move(ep));
|
||||
}
|
||||
|
||||
/** @see onnx::Params::cfgAddExecutionProvider. */
|
||||
void cfgAddExecutionProvider(ep::CoreML&& ep) {
|
||||
desc.execution_providers.emplace_back(std::move(ep));
|
||||
}
|
||||
|
||||
/** @see onnx::Params::cfgAddExecutionProvider. */
|
||||
void cfgAddExecutionProvider(ep::CUDA&& ep) {
|
||||
desc.execution_providers.emplace_back(std::move(ep));
|
||||
|
||||
Reference in New Issue
Block a user