add-ttir-d2m-lowering

Automate TTIR elementwise lowering to D2M for TTMetal in MLIR.

295|145|Updated Jun 17, 2024
One-click install
npx skills add https://github.com/tenstorrent/tt-mlir --skill add-ttir-d2m-lowering
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-ttir-d2m-lowering
Source: https://github.com/tenstorrent/tt-mlir/tree/main/.claude/skills/add-ttir-d2m-lowering
Command: npx skills add https://github.com/tenstorrent/tt-mlir --skill add-ttir-d2m-lowering

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide provides a structured, end-to-end approach for implementing TTIR elementwise → D2M lowering for TTMetal, capturing the required edits, integration steps, and constraints so teams can extend the lowering reliably without breaking existing flows.

Core Features & Use Cases

  • Guided edits: Identify and modify the correct components (TTIRToD2M.cpp, D2MGenericRegionOps.td, and related tiles) to support a new elementwise operation.
  • Kernel integration: Update TTKernelIncludesMap.h and ensure the generated TTKernel code paths remain consistent with existing patterns.
  • Test coverage: Extend lit tests, add TTIR snippets, and create golden mappings to validate the new lowering path across TTIR, D2M, and TTKernel stages.

Use Case: When introducing a new elementwise operation, follow this skill to wire the operation through tablegen, the D2M rewriter, and the TTKernel backend, ensuring deterministic, testable results.

Quick Start

Follow the checklist in this skill to implement a new TTIR→D2M lowering for an elementwise op, including edits to TTIRToD2MPatterns, D2MToTTKernel mappings, and golden/tests.

Frequently Asked Questions about add-ttir-d2m-lowering

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I lower a new elementwise op from TTIR to D2M in TTMetal?

To lower a new elementwise op from TTIR to D2M, modify TTIRToD2MPatterns, update tablegen definitions, and map kernel includes to ensure consistent code generation across the MLIR pipeline.

What files need to be edited to add a new TTIR to D2M lowering path?

Adding a TTIR to D2M lowering path requires editing TTIRToD2M.cpp, D2MGenericRegionOps.td, D2MToTTKernel.cpp, and TTKernelIncludesMap.h to wire the operation through the compiler backend.

How does TTMetal handle elementwise op lowering through the MLIR compiler?

TTMetal handles elementwise op lowering by passing TTIR operations through D2M rewriter patterns and mapping them to TTKernel code, ensuring deterministic and testable results across compiler stages.

What testing is required when implementing TTIR to D2M lowering for TTMetal?

Testing TTIR to D2M lowering requires extending lit tests, adding TTIR snippets, and creating golden artifacts to validate the new lowering path across TTIR, D2M, and TTKernel stages.

Can I use tablegen to define new elementwise operations for the TTMetal D2M path?

Yes, you can use tablegen to define new elementwise operations by updating D2MGenericRegionOps.td, which integrates the operation into the TTIR to D2M lowering pipeline.

Why do my TTKernel code paths break when adding new elementwise ops to TTMetal?

TTKernel code paths break when TTKernelIncludesMap.h is not updated, causing inconsistencies between the D2M rewriter patterns and the generated kernel code for new elementwise operations.