#define MV_INFERENCE_BACKEND_TYPE "MV_INFERENCE_BACKEND_TYPE"
/**
+ * @deprecated Deprecated since 6.0. Use #MV_INFERENCE_TARGET_TYPE instead.
* @brief Defines #MV_INFERENCE_TARGET_TYPE to set the type used
* for device running attribute of the engine configuration.
* @details Switches between CPU, GPU, or Custom:\n
* #MV_INFERENCE_TARGET_CPU (Deprecated),\n
* #MV_INFERENCE_TARGET_GPU (Deprecated),\n
* #MV_INFERENCE_TARGET_CUSTOM (Deprecated).\n
+ *
+ * The default type is CPU.
+ *
+ * @since_tizen 5.5
+ * @see mv_engine_config_set_int_attribute()
+ * @see mv_engine_config_get_int_attribute()
+ */
+#define MV_INFERENCE_TARGET_TYPE "MV_INFERENCE_TARGET_TYPE"
+
+/**
+ * @brief Defines #MV_INFERENCE_TARGET_DEVICE_TYPE to set the type used
+ * for device running attribute of the engine configuration.
+ * @details Switches between CPU, GPU, or Custom:\n
* #MV_INFERENCE_TARGET_DEVICE_CPU,\n
* #MV_INFERENCE_TARGET_DEVICE_GPU,\n
* #MV_INFERENCE_TARGET_DEVICE_CUSTOM.\n
*
- * The default type is CPU. Please do not use deprecated types since Tizen 6.0.
- * Old ones have been deprecated.
+ * The default type is CPU.
*
- * @since_tizen 5.5
+ * @since_tizen 6.0
* @see mv_engine_config_set_int_attribute()
* @see mv_engine_config_get_int_attribute()
*/
-#define MV_INFERENCE_TARGET_TYPE "MV_INFERENCE_TARGET_TYPE"
+#define MV_INFERENCE_TARGET_DEVICE_TYPE "MV_INFERENCE_TARGET_DEVICE_TYPE"
/**
* @brief Defines #MV_INFERENCE_INPUT_TENSOR_WIDTH to set the width
using namespace mediavision::inference;
-static bool is_new_mv_inference_engine(mv_engine_config_h engine_config)
+static int check_mv_inference_engine_version(mv_engine_config_h engine_config, bool *is_new_version)
{
- int dataType = 0;
+ int oldType = 0, newType = 0;
int ret = mv_engine_config_get_int_attribute(engine_config,
- MV_INFERENCE_INPUT_DATA_TYPE,
- &dataType);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- return false;
+ MV_INFERENCE_TARGET_TYPE,
+ &oldType);
+ if (ret != MEDIA_VISION_ERROR_NONE)
+ oldType = -1;
+
+ ret = mv_engine_config_get_int_attribute(engine_config,
+ MV_INFERENCE_TARGET_DEVICE_TYPE,
+ &newType);
+ if (ret != MEDIA_VISION_ERROR_NONE)
+ newType = -1;
+
+ // At least one of two target device types of
+ // media-vision-config.json file should have CPU device.
+ if (oldType == -1 && newType == -1)
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+
+ // If values of both types are changed then return an error.
+ // only one of two types should be used.
+ if (oldType != MV_INFERENCE_TARGET_CPU && newType != MV_INFERENCE_TARGET_DEVICE_CPU) {
+ LOGE("Please use only one of below two device types.");
+ LOGE("MV_INFERENCE_TARGET_TYPE(deprecated) or MV_INFERENCE_TARGET_DEVICE_TYPE(recommended).");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
}
- return true;
+ LOGI("oldType = %d, newType = %d", oldType, newType);
+
+ // If default value of only old type is changed then use old type.
+ // Otherwise, use new type in following cases,
+ // - all default values of two types aren't changed.
+ // (oldType == MV_INFERENCE_TARGET_CPU && newType == MV_INFERENCE_TARGET_DEVICE_CPU)
+ // - default value of only new type is changed.
+ // (oldType == MV_INFERENCE_TARGET_CPU && (newType != -1 && newType != MV_INFERENCE_TARGET_DEVICE_CPU))
+ if ((oldType != -1 && oldType != MV_INFERENCE_TARGET_CPU) && newType == MV_INFERENCE_TARGET_DEVICE_CPU)
+ *is_new_version = false;
+ else
+ *is_new_version = true;
+
+ return MEDIA_VISION_ERROR_NONE;
}
mv_engine_config_h mv_inference_get_engine_config(mv_inference_h infer)
}
ret = mv_engine_config_get_int_attribute(engine_config,
- MV_INFERENCE_TARGET_TYPE,
+ MV_INFERENCE_TARGET_DEVICE_TYPE,
&targetTypes);
if (ret != MEDIA_VISION_ERROR_NONE) {
LOGE("Fail to get inference target type");
goto _ERROR_;
}
+ bool is_new_version;
+
// Check if new inference engine framework or old one.
// new inference engine framework has different mv_inference_target_type_e enumeration values
// to support multiple inference target devices. So in case of old version,
// enumeration value given by user should be converted to new value, which
// will be done at ConfigureTargetTypes callback internally.
- if (is_new_mv_inference_engine(engine_config) == false) {
- ret = pInfer->ConfigureTargetTypes(targetTypes);
- if (ret != MEDIA_VISION_ERROR_NONE) {
+ // Ps. this function will be dropped with deprecated code version-after-next of Tizen.
+ ret = check_mv_inference_engine_version(engine_config, &is_new_version);
+ if (ret != MEDIA_VISION_ERROR_NONE)
+ goto _ERROR_;
+
+ if (is_new_version) {
+ // Use new type.
+ if (pInfer->ConfigureTargetDevices(targetTypes) != MEDIA_VISION_ERROR_NONE) {
LOGE("Tried to configure invalid target types.");
goto _ERROR_;
}
} else {
- ret = pInfer->ConfigureTargetDevices(targetTypes);
- if (ret != MEDIA_VISION_ERROR_NONE) {
+ // Convert old type to new one and then use it.
+ if (pInfer->ConfigureTargetTypes(targetTypes) != MEDIA_VISION_ERROR_NONE) {
LOGE("Tried to configure invalid target types.");
goto _ERROR_;
}