Skip to content

Commit

Permalink
fix C++ bitwidth 6 & 7 decompression
Browse files Browse the repository at this point in the history
  • Loading branch information
ddavis-2015 committed Oct 18, 2024
1 parent efedcc2 commit a110e41
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions tensorflow/lite/micro/kernels/decompress_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ template void DecompressionState::DecompressToBufferWidthAny(int16_t*);
template void DecompressionState::DecompressToBufferWidthAny(int32_t*);
template void DecompressionState::DecompressToBufferWidthAny(int64_t*);

// TODO(ddavis-2015): untested
inline size_t DecompressionState::GetNextTableIndexWidth7(
const size_t current_offset) {
const size_t current_byte_index = (current_offset >> 3) * 7;
Expand All @@ -428,7 +427,7 @@ inline size_t DecompressionState::GetNextTableIndexWidth7(
case 1:
return ((indices[0] & 0b1) << 6) | (indices[1] >> 2);
case 2:
return ((indices[1] & 0b11) << 4) | (indices[2] >> 3);
return ((indices[1] & 0b11) << 5) | (indices[2] >> 3);
case 3:
return ((indices[2] & 0b111) << 4) | (indices[3] >> 4);
case 4:
Expand All @@ -444,7 +443,6 @@ inline size_t DecompressionState::GetNextTableIndexWidth7(
return 0;
}

// TODO(ddavis-2015): untested
inline size_t DecompressionState::GetNextTableIndexWidth6(
const size_t current_offset) {
const size_t current_byte_index = (current_offset >> 2) * 3;
Expand All @@ -455,15 +453,14 @@ inline size_t DecompressionState::GetNextTableIndexWidth6(
case 1:
return ((indices[0] & 0b11) << 4) | (indices[1] >> 4);
case 2:
return ((indices[1] & 0x0F) << 4) | (indices[2] >> 6);
return ((indices[1] & 0x0F) << 2) | (indices[2] >> 6);
case 3:
return indices[2] & 0x3F;
}
// NOTREACHED
return 0;
}

// TODO(ddavis-2015): untested
inline size_t DecompressionState::GetNextTableIndexWidth5(
const size_t current_offset) {
const size_t current_byte_index = (current_offset >> 3) * 5;
Expand Down

0 comments on commit a110e41

Please sign in to comment.