Skip to content

Guard packed weights size against integer overflow in batch matrix multiply - #10842

Merged
copybara-service[bot] merged 1 commit into
google:masterfrom
prasanna8585:fix-batch-matmul-packed-size-overflow
Jul 24, 2026
Merged

Guard packed weights size against integer overflow in batch matrix multiply#10842
copybara-service[bot] merged 1 commit into
google:masterfrom
prasanna8585:fix-batch-matmul-packed-size-overflow

Conversation

@prasanna8585

Copy link
Copy Markdown
Contributor

create_batch_matrix_multiply_nc_const_weights computes the packed weights buffer size as:

packed_size = batch_size_b * n_stride * weights_stride

with no overflow protection, unlike reshape_batch_matrix_multiply_nc in the same file which already uses xnn_safe_mul for its own workspace size computation.

This uses xnn_safe_mul for the same computation here, consistent with that existing pattern.

…ltiply

create_batch_matrix_multiply_nc_const_weights computes the packed
weights buffer size as a raw multiplication:

  packed_size = batch_size_b * n_stride * weights_stride

with no overflow protection. Uses xnn_safe_mul, matching the pattern
already used elsewhere in this file and in convolution-nhwc.c.
copybara-service Bot pushed a commit that referenced this pull request Jul 24, 2026
--
ce7cce0 by prasanna8585 <prasanna8585@users.noreply.github.com>:

Guard packed weights size against integer overflow in batch matrix multiply

create_batch_matrix_multiply_nc_const_weights computes the packed
weights buffer size as a raw multiplication:

  packed_size = batch_size_b * n_stride * weights_stride

with no overflow protection. Uses xnn_safe_mul, matching the pattern
already used elsewhere in this file and in convolution-nhwc.c.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#10842 from prasanna8585:fix-batch-matmul-packed-size-overflow ce7cce0
PiperOrigin-RevId: 953455603
@copybara-service
copybara-service Bot merged commit c3da403 into google:master Jul 24, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant