Skip to content

Commit a532c8a

Browse files
authored
[JSEP] Fix inputShape index OOB in slice.ts (microsoft#25364)
Use `inputShape.length - 1` instead of `inputShape.length` to avoid out-of-bounds access.
1 parent 0d6e2d9 commit a532c8a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

js/web/lib/wasm/jsep/webgpu/ops/slice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const calculateInputIndicesImpl = (
9898
`fn calculateInputIndices(output_indices: ${output.type.indices}) -> ${input.type.indices} {
9999
var input_indices: ${input.type.indices};
100100
var carry = 0u;
101-
for (var i = ${inputShape.length}; i >= 0; i--) {
101+
for (var i = ${inputShape.length - 1}; i >= 0; i--) {
102102
let input_shape_i = ${getElementAt('uniforms.input_shape', 'i', inputShape.length)};
103103
let steps_i = ${getElementAt('uniforms.steps', 'i', inputShape.length)};
104104
let signs_i = ${getElementAt('uniforms.signs', 'i', inputShape.length)};

0 commit comments

Comments
 (0)