tools: Modify random matrix function for supporting UINT8 DTYPE 37/268237/8
authorHyunsoo Park <hance.park@samsung.com>
Fri, 17 Dec 2021 07:49:05 +0000 (16:49 +0900)
committerHyunsoo Park <hance.park@samsung.com>
Tue, 21 Dec 2021 13:16:57 +0000 (22:16 +0900)
[Version] 0.2.1-0
[Issue Type] Update feature

Change-Id: I4d404925d317558eb6b4c8170e1cc6558a76fc7c
Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
packaging/inference-engine-interface.spec
tools/src/inference_engine_cltuner.cpp

index 2777a33a2496db064d332718878fae3cf985c1ca..0fd928113ff51ef0ee5caf1d9778a600cc56082f 100644 (file)
@@ -1,6 +1,6 @@
 Name:        inference-engine-interface
 Summary:     Interface of inference engines
-Version:     0.2.0
+Version:     0.2.1
 Release:     0
 Group:       Multimedia/Framework
 License:     Apache-2.0
index 475a676e227cf469ac0daef2543fd57723425248..277dd770971659716f589ecf4f16b43a83e470e4 100644 (file)
@@ -72,7 +72,7 @@ int ConfigureInputInfo(InferenceEngineCommon* backend, Metadata& metadata,
                tensorConfig.mTensorInfo.height = layerInfo.dims[1];
        } else {
                LOGE("Invalid shape type[%d]", layerInfo.shapeType);
-               return INFERENCE_ENGINE_ERROR_INVALID_OPERATION;
+               return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER;
        }
 
        if (!inputMeta.option.empty()) {
@@ -294,8 +294,14 @@ int CheckTuneFile(std::vector<std::string>& model_paths)
        return INFERENCE_ENGINE_ERROR_NONE;
 }
 
-void CopyRandomMatrixToMemory(inference_engine_tensor_buffer& buffer, InferenceConfig tensorConfig)
+int CopyRandomMatrixToMemory(inference_engine_tensor_buffer& buffer, InferenceConfig tensorConfig)
 {
+       if (tensorConfig.mDataType <= INFERENCE_TENSOR_DATA_TYPE_NONE ||
+               tensorConfig.mDataType >= INFERENCE_TENSOR_DATA_TYPE_MAX) {
+               LOGE("tensorConfig.mDataType [%d] is not supported", tensorConfig.mDataType);
+               return INFERENCE_ENGINE_ERROR_INVALID_OPERATION;
+       }
+
        std::random_device rd;
        std::mt19937 generator(rd());
        std::uniform_real_distribution<> distribution(1.0, 255.0);
@@ -307,8 +313,12 @@ void CopyRandomMatrixToMemory(inference_engine_tensor_buffer& buffer, InferenceC
                for (int w_offset = 0; w_offset < width; w_offset++)
                        for (int ch_offset = 0; ch_offset < ch; ch_offset++) {
                                int offset = h_offset * width * ch + w_offset * ch + ch_offset;
-                               static_cast<float*>(buffer.buffer)[offset] = distribution(generator);
+                               if (tensorConfig.mDataType == INFERENCE_TENSOR_DATA_TYPE_FLOAT32)
+                                       static_cast<float*>(buffer.buffer)[offset] = distribution(generator);
+                               else
+                                       static_cast<char*>(buffer.buffer)[offset] = distribution(generator);
                        }
+       return INFERENCE_ENGINE_ERROR_NONE;
 }
 
 static gboolean process(std::vector<std::string>& model_paths,
@@ -407,7 +417,11 @@ static gboolean process(std::vector<std::string>& model_paths,
 
        for (auto& input : inputs) {
                LOGI("input.second.size :[%zu]", input.second.size);
-               CopyRandomMatrixToMemory(input.second, tensorConfig);
+               ret = CopyRandomMatrixToMemory(input.second, tensorConfig);
+               if (ret != INFERENCE_ENGINE_ERROR_NONE) {
+                       LOGE("CopyRandomMatrixToMemory failed");
+                       return FALSE;
+               }
        }
 
        std::chrono::system_clock::time_point StartTime =