From 313d3b8ba07e2b71ce92a999e14d78989177d7ef Mon Sep 17 00:00:00 2001 From: "y01000.you" Date: Thu, 31 Oct 2024 17:21:51 +0900 Subject: [PATCH] [luci-pass] Add cal_offset_2d Add a function for calculating offset of 2d tensor. ONE-DCO-1.0-Signed-off-by: young cheon --- compiler/luci/pass/src/QuantizationUtils.cpp | 5 +++++ compiler/luci/pass/src/QuantizationUtils.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/compiler/luci/pass/src/QuantizationUtils.cpp b/compiler/luci/pass/src/QuantizationUtils.cpp index 33d75ce04b4..e3099936100 100644 --- a/compiler/luci/pass/src/QuantizationUtils.cpp +++ b/compiler/luci/pass/src/QuantizationUtils.cpp @@ -292,6 +292,11 @@ uint32_t cal_offset(loco::TensorShape &dimension, uint32_t *indices) indices[2] * dimension.dim(3).value() + indices[3]; } +uint32_t cal_offset_2d(loco::TensorShape &dimension, uint32_t *indices) +{ + return indices[0] * dimension.dim(1).value() + indices[1]; +} + // Activation (ofm) qtype is determined in different ways. // 1. Pre-defined values: Some Ops have pre-defined qparams (ex: LOGISTIC, TANH) // 2. Integer scale: Output of some Ops should be integers (ex: FLOOR, CEIL) diff --git a/compiler/luci/pass/src/QuantizationUtils.h b/compiler/luci/pass/src/QuantizationUtils.h index 0bf3270d5ec..290ee1786db 100644 --- a/compiler/luci/pass/src/QuantizationUtils.h +++ b/compiler/luci/pass/src/QuantizationUtils.h @@ -53,6 +53,7 @@ bool get_channel_dim_index(CircleConst *node, loco::TensorShape &dimension, // Calculate offset of the given indices in dimension uint32_t cal_offset(loco::TensorShape &dimension, uint32_t *indices); +uint32_t cal_offset_2d(loco::TensorShape &dimension, uint32_t *indices); // Backward propagation of concatenation qparam void propagate_concat_quantparam(luci::CircleConcatenation *concat); @@ -63,6 +64,8 @@ void propagate_pad_v2_quantparam(luci::CirclePadV2 *pad_v2); // Return true if the node is quantized bool is_quantized(const CircleNode *node); +uint8_t fp32_to_uint8_cast(float f); + // Return true if the node is fp32 bool is_fp32(const CircleNode *node);