Skip to content

Add end-to-end BatchNorm operator tutorial (Chinese) - #2

Closed
Happy-Carrot with Copilot wants to merge 2 commits into
mainfrom
copilot/add-batchnorm-operator
Closed

Happy-Carrot with Copilot wants to merge 2 commits into
mainfrom
copilot/add-batchnorm-operator

Conversation

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown

Ticket

Link to Github Issue

Problem description

The existing "Adding an Op" tutorial (adding-an-op.md) covers the basics using matmul but lacks depth on normalization ops with multiple inputs, optional operands, multi-output variants, and decomposition patterns. A detailed tutorial using BatchNorm as the reference op was requested.

What's changed

Added docs/src/adding-an-op-batchnorm-tutorial.md — a comprehensive Chinese-language tutorial that walks through all ~25 files touched when adding BatchNorm end-to-end. Uses real code extracted from the existing BatchNorm implementation.

Covers 12 steps across the full compiler pipeline:

  • TTIR/TTNN dialect definitions — tablegen, verifiers, comparison of required vs optional operands (AttrSizedOperandSegments)
  • Conversion passes — StableHLO→TTIR, TTIR→TTNN (including multi-output handling for Training variant), TTNN→EmitC/EmitPy (prefix swap patterns, keyword arg ordering)
  • Flatbuffer schema & serialization — table definitions, OpType union, createOp dispatch
  • Runtime — header/impl, CMake registration, program_executor dispatch, input/output refs
  • OpModel interface — full implementation and stub patterns
  • TTIRBuilder & golden functions — @tag/@parse/@split methods, GoldenMapTensor limitations
  • Tests — lit tests, EmitC/EmitPy tests, Python golden tests, StableHLO conversion tests
  • TTIR decomposition — NCHW normalization strategy unique to BatchNorm

Also highlights key pitfalls: emitOpError() vs notifyMatchFailure() in pattern rewriters, attribute type mapping (I32Attr → get_signless), EmitPy positional/keyword arg ordering.

Updated docs/src/SUMMARY.md to add navigation entry under "Adding an op".

Checklist

  • New/Existing tests provide coverage for changes

Copilot AI and others added 2 commits April 16, 2026 12:58
…rification methods

Agent-Logs-Url: https://github.com/Happy-Carrot/tt-mlir/sessions/54b40344-8552-4afd-953d-11952443873e

Co-authored-by: Happy-Carrot <43030596+Happy-Carrot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Happy-Carrot/tt-mlir/sessions/54b40344-8552-4afd-953d-11952443873e

Co-authored-by: Happy-Carrot <43030596+Happy-Carrot@users.noreply.github.com>
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.

2 participants