Skip to content

Commit

Permalink
[luci-pass] Add cal_offset_2d
Browse files Browse the repository at this point in the history
Add a function for calculating offset of 2d tensor.

ONE-DCO-1.0-Signed-off-by: young cheon <[email protected]>
  • Loading branch information
y01000.you committed Oct 31, 2024
1 parent 12557d8 commit 313d3b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/luci/pass/src/QuantizationUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions compiler/luci/pass/src/QuantizationUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit 313d3b8

Please sign in to comment.