From: Inki Dae Date: Tue, 12 May 2020 07:04:26 +0000 (+0900) Subject: Check if inference target types are valid or not X-Git-Tag: submit/tizen/20200602.011936~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f3b7bf3d6b36d09aaec991978557cbd76bf46da4;p=platform%2Fcore%2Fmultimedia%2Finference-engine-interface.git Check if inference target types are valid or not Change-Id: I8ad50b13b7377dde306d052267705f5465062c32 Signed-off-by: Inki Dae --- diff --git a/src/inference_engine_common_impl.cpp b/src/inference_engine_common_impl.cpp index d85e5c4..50dac93 100755 --- a/src/inference_engine_common_impl.cpp +++ b/src/inference_engine_common_impl.cpp @@ -35,6 +35,7 @@ extern "C" { #define LOG_TAG "INFERENCE_ENGINE_COMMON" } +#define INFERENCE_TARGET_TYPE_MASK (INFERENCE_TARGET_CPU | INFERENCE_TARGET_GPU | INFERENCE_TARGET_CUSTOM) #define CHECK_ENGINE_INSTANCE(object) \ if (object == nullptr) { \ LOGE("Inference engine handle is null."); \ @@ -238,6 +239,11 @@ int InferenceEngineCommon::SetTargetDevices(int types) { CHECK_ENGINE_INSTANCE(mBackendHandle); + if (INFERENCE_TARGET_NONE >= types || INFERENCE_TARGET_TYPE_MASK < types) { + LOGE("Given target device types(%d) are invalid.", types); + return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER; + } + int ret = mBackendHandle->SetTargetDevices(types); if (ret != INFERENCE_ENGINE_ERROR_NONE) LOGE("Fail to SetTargetDevice");