Skip to content

Commit 8461ea1

Browse files
committed
fix: Add index checks to CLMaxUnpoolingLayerKernel
Resolves: COMPMID-8698 Change-Id: I447438a823c71edb38ac2a57d6ed5463bd4f4eff Signed-off-by: Walid BEN ROMDHANE <walid.benromdhane@arm.com>
1 parent 9c9151c commit 8461ea1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/core/CL/cl_kernels/common/unpooling_layer.cl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2021 Arm Limited.
2+
* Copyright (c) 2020-2021,2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -68,5 +68,9 @@ __kernel void max_unpooling_layer_2(
6868
unsigned int index = *((__global unsigned int *)indices.ptr);
6969
DATA_TYPE value = *((__global DATA_TYPE *)input.ptr);
7070

71-
*((__global DATA_TYPE *)tensor3D_index2ptr(&output, WIDTH_DST, HEIGHT_DST, DEPTH_DST, index)) = value;
72-
}
71+
unsigned int total_elements = (unsigned int) (WIDTH_DST * HEIGHT_DST * DEPTH_DST);
72+
if(index < total_elements)
73+
{
74+
*((__global DATA_TYPE *)tensor3D_index2ptr(&output, WIDTH_DST, HEIGHT_DST, DEPTH_DST, index)) = value;
75+
}
76+
}

0 commit comments

Comments
 (0)