|
| 1 | +use std::borrow::Cow; |
| 2 | + |
| 3 | +/// See [`Property`](https://docs.openvino.ai/2024/api/c_cpp_api/group__ov__property__c__api.html). |
| 4 | +/// `PropertyKey` represents valid configuration properties for a [crate::Core] instance. |
| 5 | +#[derive(Ord, PartialOrd, Eq, PartialEq, Hash, Debug)] |
| 6 | +pub enum PropertyKey { |
| 7 | + /// A string list of supported read-only properties. |
| 8 | + SupportedProperties, |
| 9 | + /// A list of available device IDs. |
| 10 | + AvailableDevices, |
| 11 | + /// An unsigned integer value of optimal number of compiled model infer requests. |
| 12 | + OptimalNumberOfInferRequests, |
| 13 | + /// A hint for a range for number of async infer requests. |
| 14 | + /// If device supports streams, the metric provides range for number of IRs per stream. |
| 15 | + RangeForAsyncInferRequests, |
| 16 | + /// Information about a range for streams on platforms where streams are supported. |
| 17 | + RangeForStreams, |
| 18 | + /// A string value representing a full device name. |
| 19 | + DeviceFullName, |
| 20 | + /// A string list of capabilities options per device. |
| 21 | + DeviceCapabilities, |
| 22 | + /// The name of a model. |
| 23 | + ModelName, |
| 24 | + /// Information about optimal batch size for the given device and network. |
| 25 | + OptimalBatchSize, |
| 26 | + /// Maximum batch size which does not cause performance degradation due to memory swap impact. |
| 27 | + MaxBatchSize, |
| 28 | + /// Read-write property key. |
| 29 | + Rw(RwPropertyKey), |
| 30 | + /// Arbitrary string property key. |
| 31 | + Other(Cow<'static, str>), |
| 32 | +} |
| 33 | + |
| 34 | +/// Read-write property keys. |
| 35 | +#[derive(Ord, PartialOrd, Eq, PartialEq, Hash, Debug)] |
| 36 | +pub enum RwPropertyKey { |
| 37 | + /// The directory which will be used to store any data cached by plugins. |
| 38 | + CacheDir, |
| 39 | + /// The cache mode between optimize_size and optimize_speed. |
| 40 | + /// If optimize_size is selected, smaller cache files will be created. |
| 41 | + /// If optimize_speed is selected, loading time will decrease but the cache file size will increase. |
| 42 | + CacheMode, |
| 43 | + /// The number of executor logical partitions. |
| 44 | + NumStreams, |
| 45 | + /// CPU affinity per thread. |
| 46 | + Affinity, |
| 47 | + /// The maximum number of threads that can be used for inference tasks. |
| 48 | + InferenceNumThreads, |
| 49 | + /// High-level OpenVINO hint for using CPU pinning to bind CPU threads to processors during inference. |
| 50 | + HintEnableCpuPinning, |
| 51 | + /// High-level OpenVINO hint for using hyper threading processors during CPU inference. |
| 52 | + HintEnableHyperThreading, |
| 53 | + /// High-level OpenVINO Performance Hints. |
| 54 | + HintPerformanceMode, |
| 55 | + /// High-level OpenVINO Hints for the type of CPU core used during inference. |
| 56 | + HintSchedulingCoreType, |
| 57 | + /// Hint for device to use specified precision for inference. |
| 58 | + HintInferencePrecision, |
| 59 | + /// Backs the Performance Hints by giving |
| 60 | + /// additional information on how many inference requests the application will be |
| 61 | + /// keeping in flight usually this value comes from the actual use-case (e.g. |
| 62 | + /// number of video-cameras, or other sources of inputs) |
| 63 | + HintNumRequests, |
| 64 | + /// Desirable log level. |
| 65 | + LogLevel, |
| 66 | + /// High-level OpenVINO model priority hint. |
| 67 | + HintModelPriority, |
| 68 | + /// Performance counters. |
| 69 | + EnableProfiling, |
| 70 | + /// Device Priorities config option, |
| 71 | + /// with comma-separated devices listed in the desired priority. |
| 72 | + DevicePriorities, |
| 73 | + /// High-level OpenVINO Execution hint |
| 74 | + /// unlike low-level properties that are individual (per-device), the hints are something that every device accepts |
| 75 | + /// and turns into device-specific settings |
| 76 | + /// Execution mode hint controls preferred optimization targets (performance or accuracy) for given model |
| 77 | + /// |
| 78 | + /// It can be set to be below value: |
| 79 | + /// - `"PERFORMANCE"`: Optimize for max performance |
| 80 | + /// - `"ACCURACY"`: Optimize for max accuracy |
| 81 | + HintExecutionMode, |
| 82 | + /// Whether to force terminate TBB when OV Core is destroyed. |
| 83 | + ForceTbbTerminate, |
| 84 | + /// Configure `mmap()` use for model read. |
| 85 | + EnableMmap, |
| 86 | + /// ? |
| 87 | + AutoBatchTimeout, |
| 88 | + /// Arbitrary string property key. |
| 89 | + Other(Cow<'static, str>), |
| 90 | +} |
| 91 | + |
| 92 | +impl AsRef<str> for PropertyKey { |
| 93 | + fn as_ref(&self) -> &str { |
| 94 | + match self { |
| 95 | + PropertyKey::SupportedProperties => "SUPPORTED_PROPERTIES", |
| 96 | + PropertyKey::AvailableDevices => "AVAILABLE_DEVICES", |
| 97 | + PropertyKey::OptimalNumberOfInferRequests => "OPTIMAL_NUMBER_OF_INFER_REQUESTS", |
| 98 | + PropertyKey::RangeForAsyncInferRequests => "RANGE_FOR_ASYNC_INFER_REQUESTS", |
| 99 | + PropertyKey::RangeForStreams => "RANGE_FOR_STREAMS", |
| 100 | + PropertyKey::DeviceFullName => "FULL_DEVICE_NAME", |
| 101 | + PropertyKey::DeviceCapabilities => "OPTIMIZATION_CAPABILITIES", |
| 102 | + PropertyKey::ModelName => "NETWORK_NAME", |
| 103 | + PropertyKey::OptimalBatchSize => "OPTIMAL_BATCH_SIZE", |
| 104 | + PropertyKey::MaxBatchSize => "MAX_BATCH_SIZE", |
| 105 | + PropertyKey::Rw(rw) => rw.as_ref(), |
| 106 | + PropertyKey::Other(s) => s, |
| 107 | + } |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +impl AsRef<str> for RwPropertyKey { |
| 112 | + fn as_ref(&self) -> &str { |
| 113 | + match self { |
| 114 | + RwPropertyKey::CacheDir => "CACHE_DIR", |
| 115 | + RwPropertyKey::CacheMode => "CACHE_MODE", |
| 116 | + RwPropertyKey::NumStreams => "NUM_STREAMS", |
| 117 | + RwPropertyKey::Affinity => "AFFINITY", |
| 118 | + RwPropertyKey::InferenceNumThreads => "INFERENCE_NUM_THREADS", |
| 119 | + RwPropertyKey::HintEnableCpuPinning => "ENABLE_CPU_PINNING", |
| 120 | + RwPropertyKey::HintEnableHyperThreading => "ENABLE_HYPER_THREADING", |
| 121 | + RwPropertyKey::HintPerformanceMode => "PERFORMANCE_HINT", |
| 122 | + RwPropertyKey::HintSchedulingCoreType => "SCHEDULING_CORE_TYPE", |
| 123 | + RwPropertyKey::HintInferencePrecision => "INFERENCE_PRECISION_HINT", |
| 124 | + RwPropertyKey::HintNumRequests => "PERFORMANCE_HINT_NUM_REQUESTS", |
| 125 | + RwPropertyKey::LogLevel => "LOG_LEVEL", |
| 126 | + RwPropertyKey::HintModelPriority => "MODEL_PRIORITY", |
| 127 | + RwPropertyKey::EnableProfiling => "PERF_COUNT", |
| 128 | + RwPropertyKey::DevicePriorities => "MULTI_DEVICE_PRIORITIES", |
| 129 | + RwPropertyKey::HintExecutionMode => "EXECUTION_MODE_HINT", |
| 130 | + RwPropertyKey::ForceTbbTerminate => "FORCE_TBB_TERMINATE", |
| 131 | + RwPropertyKey::EnableMmap => "ENABLE_MMAP", |
| 132 | + RwPropertyKey::AutoBatchTimeout => "AUTO_BATCH_TIMEOUT", |
| 133 | + RwPropertyKey::Other(s) => s, |
| 134 | + } |
| 135 | + } |
| 136 | +} |
0 commit comments