mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-18 07:29:45 +00:00
perf(axelera): quantize uint8->int8 in one wrapping pass
resized - 128 in uint8 wraps mod 256, then astype(int8) yields exactly px - 128 (verified for all 0..255, equivalent to the int16+clip path) without the intermediate int16 array or clip pass.
This commit is contained in:
parent
92112cf909
commit
44cc8bf4fc
@ -369,8 +369,9 @@ class _AxeleraRuntimeInference:
|
||||
(self._new_w, self._new_h),
|
||||
interpolation=cv2.INTER_LINEAR,
|
||||
)
|
||||
q = resized.astype(np.int16) - 128 # uint8 [0,255] -> int8 [-128,127]
|
||||
q = np.clip(q, -128, 127).astype(np.int8)
|
||||
# uint8 - 128 wraps mod 256, then cast to int8 == px - 128 (exactly),
|
||||
# in one pass over the resized frame (no int16/clip intermediates)
|
||||
q = (resized - np.uint8(128)).astype(np.int8)
|
||||
buf = self._in_buf
|
||||
buf.fill(INPUT_Q_ZERO)
|
||||
y0, y1 = self._pad_t, self._pad_t + self._new_h
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user