From 7559ee789e7d38e717ca5083af4008bad1d3116b Mon Sep 17 00:00:00 2001 From: Inki Dae Date: Wed, 6 Nov 2024 13:28:26 +0900 Subject: [PATCH] add quantization type to tensor info [Version] : 0.5.1 [Issue type] : new feature Add quantization type to tensor info. Change-Id: I502f90b22ee86393f88760ad0a4cebc8c0a4af09 Signed-off-by: Inki Dae --- include/inference_engine_type.h | 11 +++++++++++ packaging/inference-engine-interface.spec | 2 +- test/src/inference_engine_profiler.cpp | 19 +++++++++++-------- test/src/inference_engine_tc.cpp | 13 +++++++------ tools/src/inference_engine_cltuner.cpp | 2 +- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/include/inference_engine_type.h b/include/inference_engine_type.h index 243af02..6c5d1e5 100644 --- a/include/inference_engine_type.h +++ b/include/inference_engine_type.h @@ -115,6 +115,16 @@ extern "C" INFERENCE_TENSOR_DATA_TYPE_MAX } inference_tensor_data_type_e; + /** + * @brief Enumeration for Tensor quantization type. + * + * @since_tizen 9.0 + */ + typedef enum { + INFERENCE_TENSOR_QUANTIZATION_NONE = 0, + INFERENCE_TENSOR_QUANTIZATION_AFFINE, /** < Affine quantization */ + } inference_tensor_quantization_type_e; + /** * @brief Enumeration for OPenCL Tuner type. * @@ -211,6 +221,7 @@ extern "C" 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. */ + inference_tensor_quantization_type_e quantization_type; /**< a quantization type of the layer. */ // TODO. } inference_engine_tensor_info; diff --git a/packaging/inference-engine-interface.spec b/packaging/inference-engine-interface.spec index f425ebb..1541d70 100644 --- a/packaging/inference-engine-interface.spec +++ b/packaging/inference-engine-interface.spec @@ -1,6 +1,6 @@ Name: inference-engine-interface Summary: Interface of inference engines -Version: 0.5.0 +Version: 0.5.1 Release: 0 Group: Multimedia/Framework License: Apache-2.0 diff --git a/test/src/inference_engine_profiler.cpp b/test/src/inference_engine_profiler.cpp index 15786fb..d111725 100644 --- a/test/src/inference_engine_profiler.cpp +++ b/test/src/inference_engine_profiler.cpp @@ -258,7 +258,7 @@ TEST_P(InferenceEngineTfliteTest, Inference) (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW, (inference_tensor_data_type_e) tensor_type, (size_t)(1 * ch * height * width), - 0.0f, 0 + 0.0f, 0, INFERENCE_TENSOR_QUANTIZATION_NONE }; for (auto& layer : input_layers) { @@ -276,7 +276,8 @@ TEST_P(InferenceEngineTfliteTest, Inference) INFERENCE_TENSOR_DATA_TYPE_FLOAT32, 1, 0.0f, - 0 + 0, + INFERENCE_TENSOR_QUANTIZATION_NONE }; for (auto& layer : output_layers) { @@ -458,7 +459,7 @@ TEST_P(InferenceEngineTfliteCLTunerTest, Inference) INFERENCE_TENSOR_SHAPE_NCHW, static_cast(tensor_type), static_cast(1 * ch * height * width), - 0.0f, 0 + 0.0f, 0, INFERENCE_TENSOR_QUANTIZATION_NONE }; for (auto& input : input_layers) { @@ -476,7 +477,8 @@ TEST_P(InferenceEngineTfliteCLTunerTest, Inference) INFERENCE_TENSOR_DATA_TYPE_FLOAT32, 1, 0.0f, - 0 + 0, + INFERENCE_TENSOR_QUANTIZATION_NONE }; for (auto& layer : output_layers) { @@ -632,7 +634,7 @@ TEST_P(InferenceEngineCaffeTest, Inference) INFERENCE_TENSOR_SHAPE_NCHW, (inference_tensor_data_type_e) tensor_type, (size_t)(1 * ch * height * width), - 0.0f, 0 + 0.0f, 0, INFERENCE_TENSOR_QUANTIZATION_NONE }; for (auto& layer : input_layers) { @@ -650,7 +652,8 @@ TEST_P(InferenceEngineCaffeTest, Inference) INFERENCE_TENSOR_DATA_TYPE_FLOAT32, 1, 0.0f, - 0 + 0, + INFERENCE_TENSOR_QUANTIZATION_NONE }; for (auto& layer : output_layers) { @@ -799,7 +802,7 @@ TEST_P(InferenceEngineDldtTest, Inference) INFERENCE_TENSOR_SHAPE_NCHW, (inference_tensor_data_type_e) tensor_type, (size_t)(1 * ch * height * width), - 0.0f, 0 + 0.0f, 0, INFERENCE_TENSOR_QUANTIZATION_NONE }; for (auto& layer : input_layers) { @@ -816,7 +819,7 @@ TEST_P(InferenceEngineDldtTest, Inference) INFERENCE_TENSOR_SHAPE_NCHW, (inference_tensor_data_type_e) tensor_type, (size_t)(1 * ch * height * width), - 0.0f, 0 + 0.0f, 0, INFERENCE_TENSOR_QUANTIZATION_NONE }; for (auto& layer : output_layers) { diff --git a/test/src/inference_engine_tc.cpp b/test/src/inference_engine_tc.cpp index f8d8bca..d37116a 100644 --- a/test/src/inference_engine_tc.cpp +++ b/test/src/inference_engine_tc.cpp @@ -330,7 +330,7 @@ TEST_P(InferenceEngineTestCase_G4, SetInputLayer_P) (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW, (inference_tensor_data_type_e) tensor_type, (size_t)(1 * ch * height * width), - 0.0f, 0 + 0.0f, 0, INFERENCE_TENSOR_QUANTIZATION_NONE }; input_property.layers.insert(std::make_pair(layer, tensor_info)); @@ -367,7 +367,7 @@ TEST_P(InferenceEngineTestCase_G5, SetInputLayer_N1) (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW, (inference_tensor_data_type_e) tensor_type, (size_t)(1 * ch * height * width), - 0.0f, 0 + 0.0f, 0, INFERENCE_TENSOR_QUANTIZATION_NONE }; output_property.layers.insert(std::make_pair(layer, tensor_info)); @@ -424,7 +424,7 @@ TEST_P(InferenceEngineTestCase_G4, SetOutputLayer_P) (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW, (inference_tensor_data_type_e) tensor_type, (size_t)(1 * ch * height * width), - 0.0f, 0 + 0.0f, 0, INFERENCE_TENSOR_QUANTIZATION_NONE }; output_property.layers.insert(std::make_pair(layer, tensor_info)); @@ -461,7 +461,7 @@ TEST_P(InferenceEngineTestCase_G5, SetOutputLayer_N1) (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW, (inference_tensor_data_type_e) tensor_type, (size_t)(1 * ch * height * width), - 0.0f, 0 + 0.0f, 0, INFERENCE_TENSOR_QUANTIZATION_NONE }; output_property.layers.insert(std::make_pair(layer, tensor_info)); @@ -575,7 +575,7 @@ TEST_P(InferenceEngineTestCase_G6, Inference_P) (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW, (inference_tensor_data_type_e) tensor_type, (size_t)(1 * ch * height * width), - 0.0f, 0 + 0.0f, 0, INFERENCE_TENSOR_QUANTIZATION_NONE }; for (auto& layer : input_layers) { @@ -592,7 +592,8 @@ TEST_P(InferenceEngineTestCase_G6, Inference_P) INFERENCE_TENSOR_DATA_TYPE_FLOAT32, 1, 0.0f, - 0}; + 0, + INFERENCE_TENSOR_QUANTIZATION_NONE}; for (auto& layer : output_layers) { output_property.layers.insert(std::make_pair(layer, output_tensor_info)); } diff --git a/tools/src/inference_engine_cltuner.cpp b/tools/src/inference_engine_cltuner.cpp index aa082fa..aee9bc4 100644 --- a/tools/src/inference_engine_cltuner.cpp +++ b/tools/src/inference_engine_cltuner.cpp @@ -166,7 +166,7 @@ int ConfigureOutputInfo(InferenceEngineCommon* backend, Metadata& metadata, inference_engine_layer_property property; inference_engine_tensor_info tensor_info = { std::vector{1}, INFERENCE_TENSOR_SHAPE_NCHW, - INFERENCE_TENSOR_DATA_TYPE_FLOAT32, 1, 0.0f, 0}; + INFERENCE_TENSOR_DATA_TYPE_FLOAT32, 1, 0.0f, 0, INFERENCE_TENSOR_QUANTIZATION_NONE}; for (auto& name : tensorConfig.mOutputLayerNames) { LOGI("Configure %s layer as output", name.c_str()); -- 2.34.1