pypto-case-matmul-2d

Generate tiled 2D matmul kernels with tail handling using the pypto DSL.

258|48|Updated Jun 22, 2020
One-click install
npx skills add https://github.com/mindspore-ai/akg --skill pypto-case-matmul-2d-mindspore-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pypto-case-matmul-2d
Source: https://github.com/mindspore-ai/akg/tree/main/akg_agents/python/akg_agents/op/resources/skills/pypto/cases/pypto-case-matmul-2d
Command: npx skills add https://github.com/mindspore-ai/akg --skill pypto-case-matmul-2d-mindspore-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill demonstrates generation of high-performance 2D matrix multiplication kernels using the pypto DSL with loop tiling and tail handling to optimize large-scale matmul workloads on Ascend.

Core Features & Use Cases

  • Loop tiling with BASIC_BATCH to partition matrices and enable efficient on-device computation.
  • Tail handling gracefully processes remaining rows when the matrix dimension is not a multiple of the tile size.
  • Two-phase approach supports matmul and optional bias addition (linear) for end-to-end kernel pipelines.
  • 3D inputs can be reshaped to 2D blocks for batched matmul while preserving correctness and performance.

Quick Start

Use this Skill to generate a tiled 2D matmul kernel with tail handling for M-dimension loops using the pypto DSL on Ascend.

Frequently Asked Questions about pypto-case-matmul-2d

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

FAQPage Schema
How do I generate a high-performance 2D matmul kernel with loop tiling on Ascend?

You can generate high-performance 2D matmul kernels with loop tiling on Ascend using the pypto DSL, which partitions matrices using compile-time constants like BASIC_BATCH to enable efficient on-device computation.

What is tail handling in matrix multiplication and why is it needed?

Tail handling in matrix multiplication processes remaining rows when the matrix dimension is not a multiple of the tile size, ensuring computation correctness without sacrificing overall tiling performance.

Can I process batched 3D tensors for matmul using the pypto DSL?

Yes, you can process batched 3D tensors for matmul by reshaping them into 2D blocks, preserving correctness and performance while applying the tiled 2D matmul kernel.

Does the generated matmul kernel support adding a bias stage for linear operations?

Yes, the generated matmul kernel supports an optional bias addition stage for linear operations, utilizing a two-phase workflow to execute end-to-end kernel pipelines.

What is the best way to handle matrix dimensions that are not multiples of the tile size?

The best way to handle non-multiple matrix dimensions is using tail handling logic, which gracefully processes the remaining rows when the matrix dimension does not evenly divide by the tile size.