Skip to content

Comments

codegen: add MatMul operator support#9

Merged
strimo378 merged 1 commit intomainfrom
codex/implement-matrix-multiplication-operator
Jan 10, 2026
Merged

codegen: add MatMul operator support#9
strimo378 merged 1 commit intomainfrom
codex/implement-matrix-multiplication-operator

Conversation

@strimo378
Copy link
Contributor

Motivation

  • Provide end-to-end support for the ONNX MatMul operator including lowering, C code emission, and runtime execution.
  • Generate shape-aware C kernels for matrix multiply to keep emitted signatures precise and deterministic.
  • Ensure correctness by adding unit/golden tests and ORT comparison for MatMul.

Description

  • Add a MatMulOp dataclass and extend LoweredModel with input_shapes so codegen can emit shape-specific signatures.
  • Implement _lower_matmul in compiler.py with 2D shape validation and inner-dimension checks, and add _apply_matmul for runtime execution.
  • Extend CEmitter to render MatMulOp using a new templates/matmul_op.c.j2 template and include MatMulOp in op resolution and wrapper emission.
  • Add golden output tests/golden/matmul_model.c and tests in tests/test_add_mvp.py to validate emitted code and numerical equality against ONNX Runtime.

Testing

  • Ran pytest -n auto -q and all tests passed (10 passed).
  • New tests include a golden file comparison (matmul_model.c) and an ONNX Runtime numeric comparison for MatMul.

Codex Task

@strimo378 strimo378 merged commit 61f2a72 into main Jan 10, 2026
0 of 2 checks passed
@strimo378 strimo378 deleted the codex/implement-matrix-multiplication-operator branch January 10, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant