burn icon indicating copy to clipboard operation
burn copied to clipboard

MatMulInteger

Open NewBornRustacean opened this issue 9 months ago • 3 comments

Add MatMulInteger ONNX operation to Burn

Hello, Burn community! I'm trying to add MatMulInteger to burn-import

Checklist

  • [ ] Confirmed that run-checks all script has been executed.
  • [ ] Made sure the book is up to date with changes in this PR.

Related Issues/PRs

This PR addresses part of issue #1714 which requests implementation of missing ONNX operations in the burn-import crate. Specifically, it implements the MatMulInteger operation which was listed under "Harder Ops (Not Similar to Existing Implemented Ops)".

Changes

This PR implements the MatMulInteger (ONNX opset 10) operation in the burn-import crate, allowing users to import ONNX models that utilize quantized matrix multiplication. The implementation:

  1. Creates a new MatMulIntegerNode structure to handle the operation
  2. Implements proper dimension handling and broadcasting for tensors with different ranks
  3. Supports optional zero points for quantized inputs (both scalar and tensor)
  4. Follows the ONNX specification for integer matrix multiplication
  5. Handles the conversion of quantized inputs with appropriate zero point subtraction

Testing

  • [x] Unit tests for code generation that verify the correct Rust code is produced
  • [ ] Validation of tensor types to ensure compatibility with ONNX specifications (int8/uint8 inputs, int32 outputs)
  • [ ] Proper handling of different tensor dimensions with broadcasting
  • [ ] Tests for both scalar and tensor-based zero points

Additional integration tests with actual ONNX models containing the MatMulInteger op will be added.

NewBornRustacean avatar Feb 26 '25 08:02 NewBornRustacean

Also, ignore the macos CI failing.. we're having issues with the space on the runners since yesterday 🥲

laggui avatar Feb 26 '25 14:02 laggui

Codecov Report

Attention: Patch coverage is 79.87013% with 31 lines in your changes missing coverage. Please review.

Project coverage is 82.17%. Comparing base (2dfb3d4) to head (5cb4e2a). Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crates/burn-import/src/burn/node/matmul_integer.rs 79.87% 31 Missing :warning:

:x: Your patch check has failed because the patch coverage (79.87%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #2846    +/-   ##
========================================
  Coverage   82.17%   82.17%            
========================================
  Files         854      855     +1     
  Lines      114001   114214   +213     
========================================
+ Hits        93676    93858   +182     
- Misses      20325    20356    +31     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 26 '25 14:02 codecov[bot]

This PR has been marked as stale because it has not been updated for over a month

github-actions[bot] avatar Apr 01 '25 12:04 github-actions[bot]

This PR has been marked as stale because it has not been updated for over a month

github-actions[bot] avatar Sep 03 '25 12:09 github-actions[bot]

Implemented by https://github.com/tracel-ai/burn/pull/3672

antimora avatar Sep 10 '25 14:09 antimora