Skip to content

Commit

Permalink
[cpu] Cast pixel to number in maxpool utils (#7534)
Browse files Browse the repository at this point in the history
This is in preparation for TypeScript 5.0. See cl/520770605 for details.
  • Loading branch information
mattsoulanille authored Mar 31, 2023
1 parent 430bc13 commit 53e17f6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tfjs-backend-cpu/src/utils/pool_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ export function maxPoolPositions(
const wR = xR - xRCorner;
for (let xC = xCMin; xC < xCMax; xC += dilationWidth) {
const wC = xC - xCCorner;
const pixel = xBuf.get(b, xR, xC, d);
// For some reason, disable-next-line is not working
// TODO(mattsoulanille): Remove this when switching to TS5.
/* tslint:disable: no-unnecessary-type-assertion */
const pixel = xBuf.get(b, xR, xC, d) as number;
if (pixel > maxValue) {
maxValue = pixel as number;
if (flattenPositions) {
Expand Down Expand Up @@ -313,7 +316,8 @@ export function maxPool3dPositions(
for (let xCol = xColMin; xCol < xColMax;
xCol += dilationWidth) {
const wCol = xCol - xColCorner;
const pixel = xBuf.get(batch, xDepth, xRow, xCol, channel);
const pixel = xBuf.get(batch, xDepth, xRow, xCol,
channel) as number;
if (pixel >= maxValue) {
maxValue = pixel as number;
maxPosition =
Expand Down

0 comments on commit 53e17f6

Please sign in to comment.