add scale and zero_point members to tensor info 69/319869/2 tizen
authorInki Dae <inki.dae@samsung.com>
Tue, 5 Nov 2024 02:43:25 +0000 (11:43 +0900)
committerInki Dae <inki.dae@samsung.com>
Tue, 5 Nov 2024 03:59:37 +0000 (12:59 +0900)
[Version] : 0.5.0
[Issue type] : new feature

Add scale and zero_point menbers to tensor info.
In case of quantization model, there are some cases that
user want to get scale and zero_point values to a given tensor
to dequantize the tensor value to floting point data.

Change-Id: Ibbb55d97bba639d3069c0133b243746057f8d8bb
Signed-off-by: Inki Dae <inki.dae@samsung.com>
include/inference_engine_type.h
packaging/inference-engine-interface.spec
test/src/inference_engine_profiler.cpp
test/src/inference_engine_tc.cpp
tools/src/inference_engine_cltuner.cpp

index 702c8d7..243af02 100644 (file)
@@ -209,6 +209,8 @@ extern "C"
                inference_tensor_shape_type_e shape_type; /**< a tensor shape of the layer. */
                inference_tensor_data_type_e data_type; /**< a tensor type of the layer. */
                size_t size; /** tensor element size. The size should be height * width * channel count */
+               float scale; /**< a scale value of the layer. */
+               int zero_point; /**< a zero point value of the layer. */
                // TODO.
        } inference_engine_tensor_info;
 
index dc65358..f425ebb 100644 (file)
@@ -1,6 +1,6 @@
 Name:        inference-engine-interface
 Summary:     Interface of inference engines
-Version:     0.4.10
+Version:     0.5.0
 Release:     0
 Group:       Multimedia/Framework
 License:     Apache-2.0
index c434cf5..15786fb 100644 (file)
@@ -257,7 +257,8 @@ TEST_P(InferenceEngineTfliteTest, Inference)
                { 1, ch, height, width },
                (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW,
                (inference_tensor_data_type_e) tensor_type,
-               (size_t)(1 * ch * height * width)
+               (size_t)(1 * ch * height * width),
+               0.0f, 0
        };
 
        for (auto& layer : input_layers) {
@@ -273,7 +274,9 @@ TEST_P(InferenceEngineTfliteTest, Inference)
                std::vector<size_t>{1},
                INFERENCE_TENSOR_SHAPE_NCHW,
                INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
-               1
+               1,
+               0.0f,
+               0
        };
 
        for (auto& layer : output_layers) {
@@ -454,7 +457,8 @@ TEST_P(InferenceEngineTfliteCLTunerTest, Inference)
                { 1, ch, height, width },
                INFERENCE_TENSOR_SHAPE_NCHW,
                static_cast<inference_tensor_data_type_e>(tensor_type),
-               static_cast<size_t>(1 * ch * height * width)
+               static_cast<size_t>(1 * ch * height * width),
+               0.0f, 0
        };
 
        for (auto& input : input_layers) {
@@ -470,7 +474,9 @@ TEST_P(InferenceEngineTfliteCLTunerTest, Inference)
                std::vector<size_t>{1},
                INFERENCE_TENSOR_SHAPE_NCHW,
                INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
-               1
+               1,
+               0.0f,
+               0
        };
 
        for (auto& layer : output_layers) {
@@ -625,7 +631,8 @@ TEST_P(InferenceEngineCaffeTest, Inference)
                { 1, ch, height, width },
                INFERENCE_TENSOR_SHAPE_NCHW,
                (inference_tensor_data_type_e) tensor_type,
-               (size_t)(1 * ch * height * width)
+               (size_t)(1 * ch * height * width),
+               0.0f, 0
        };
 
        for (auto& layer : input_layers) {
@@ -641,7 +648,9 @@ TEST_P(InferenceEngineCaffeTest, Inference)
                std::vector<size_t>{1},
                INFERENCE_TENSOR_SHAPE_NCHW,
                INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
-               1
+               1,
+               0.0f,
+               0
        };
 
        for (auto& layer : output_layers) {
@@ -789,7 +798,8 @@ TEST_P(InferenceEngineDldtTest, Inference)
                { 1, ch, height, width },
                INFERENCE_TENSOR_SHAPE_NCHW,
                (inference_tensor_data_type_e) tensor_type,
-               (size_t)(1 * ch * height * width)
+               (size_t)(1 * ch * height * width),
+               0.0f, 0
        };
 
        for (auto& layer : input_layers) {
@@ -805,7 +815,8 @@ TEST_P(InferenceEngineDldtTest, Inference)
                { 1, ch, height, width },
                INFERENCE_TENSOR_SHAPE_NCHW,
                (inference_tensor_data_type_e) tensor_type,
-               (size_t)(1 * ch * height * width)
+               (size_t)(1 * ch * height * width),
+               0.0f, 0
        };
 
        for (auto& layer : output_layers) {
index b84ee4f..f8d8bca 100644 (file)
@@ -329,7 +329,8 @@ TEST_P(InferenceEngineTestCase_G4, SetInputLayer_P)
                        { 1, ch, height, width },
                        (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW,
                        (inference_tensor_data_type_e) tensor_type,
-                       (size_t)(1 * ch * height * width)
+                       (size_t)(1 * ch * height * width),
+                       0.0f, 0
                };
 
                input_property.layers.insert(std::make_pair(layer, tensor_info));
@@ -365,7 +366,8 @@ TEST_P(InferenceEngineTestCase_G5, SetInputLayer_N1)
                        { 1, ch, height, width },
                        (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW,
                        (inference_tensor_data_type_e) tensor_type,
-                       (size_t)(1 * ch * height * width)
+                       (size_t)(1 * ch * height * width),
+                       0.0f, 0
                };
 
                output_property.layers.insert(std::make_pair(layer, tensor_info));
@@ -421,7 +423,8 @@ TEST_P(InferenceEngineTestCase_G4, SetOutputLayer_P)
                        { 1, ch, height, width },
                        (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW,
                        (inference_tensor_data_type_e) tensor_type,
-                       (size_t)(1 * ch * height * width)
+                       (size_t)(1 * ch * height * width),
+                       0.0f, 0
                };
 
                output_property.layers.insert(std::make_pair(layer, tensor_info));
@@ -457,7 +460,8 @@ TEST_P(InferenceEngineTestCase_G5, SetOutputLayer_N1)
                        { 1, ch, height, width },
                        (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW,
                        (inference_tensor_data_type_e) tensor_type,
-                       (size_t)(1 * ch * height * width)
+                       (size_t)(1 * ch * height * width),
+                       0.0f, 0
                };
 
                output_property.layers.insert(std::make_pair(layer, tensor_info));
@@ -570,7 +574,8 @@ TEST_P(InferenceEngineTestCase_G6, Inference_P)
                { 1, ch, height, width },
                (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW,
                (inference_tensor_data_type_e) tensor_type,
-               (size_t)(1 * ch * height * width)
+               (size_t)(1 * ch * height * width),
+               0.0f, 0
        };
 
        for (auto& layer : input_layers) {
@@ -585,7 +590,9 @@ TEST_P(InferenceEngineTestCase_G6, Inference_P)
        inference_engine_tensor_info output_tensor_info = { std::vector<size_t>{1},
                                                        INFERENCE_TENSOR_SHAPE_NCHW,
                                                        INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
-                                                       1};
+                                                       1,
+                                                       0.0f,
+                                                       0};
        for (auto& layer : output_layers) {
                output_property.layers.insert(std::make_pair(layer, output_tensor_info));
        }
index 5c81450..aa082fa 100644 (file)
@@ -96,7 +96,7 @@ int ConfigureInputInfo(InferenceEngineCommon* backend, Metadata& metadata,
        inference_engine_layer_property property;
 
        for (auto& name : tensorConfig.mInputLayerNames) {
-               inference_engine_tensor_info tensor_info;
+               inference_engine_tensor_info tensor_info {};
 
                tensor_info.data_type = tensorConfig.mDataType;
                tensor_info.shape_type = INFERENCE_TENSOR_SHAPE_NCHW;
@@ -166,7 +166,7 @@ int ConfigureOutputInfo(InferenceEngineCommon* backend, Metadata& metadata,
        inference_engine_layer_property property;
        inference_engine_tensor_info tensor_info = {
            std::vector<size_t>{1}, INFERENCE_TENSOR_SHAPE_NCHW,
-           INFERENCE_TENSOR_DATA_TYPE_FLOAT32, 1};
+           INFERENCE_TENSOR_DATA_TYPE_FLOAT32, 1, 0.0f, 0};
 
        for (auto& name : tensorConfig.mOutputLayerNames) {
                LOGI("Configure %s layer as output", name.c_str());