Vec-to-Cube-to-Vec Pattern

【免费下载链接】cannbot-skills CANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体,本仓库为其提供可复用的 Skills 模块。 【免费下载链接】cannbot-skills 项目地址: https://gitcode.com/cann/cannbot-skills

Generic baseline only. For a2 (b3) kernels, prefer the a2-specific patterns under agent/references/patterns/ (e.g., a2-cube-vec.md, a2-cube-vec-cube.md) and read agent/references/constraints/a2-device.md for device-side rules.

Read this file when the kernel needs vec preprocessing, cube compute, and vec postprocessing in one fused flow.

Use this pattern when

  • input data needs a vec-side transform first
  • cube does the main matmul or cube-heavy stage
  • vec performs the final output transform

Minimal flow

GM -> UB -> @vf -> UB -> L1 -> L0 -> L0C -> UB -> @vf -> GM

Ownership rule

This pattern has two cross-side handoffs:

  • vec -> cube needs VcMutex
  • cube -> vec needs CvMutex

Keep those two ownership edges conceptually separate. Do not let one counter or one fuzzy stage boundary blur them together.

What usually matters most

  • separate stage counters
  • clear stage ownership
  • avoiding accidental reuse of one buffer lifetime across both handoff directions
  • keeping validation incremental instead of building the whole fusion at once

Typical files to study

  • agent/example/kernels/a5/vec_cube_vec_scale2_abs_add1_matmul.py

【免费下载链接】cannbot-skills CANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体,本仓库为其提供可复用的 Skills 模块。 【免费下载链接】cannbot-skills 项目地址: https://gitcode.com/cann/cannbot-skills

Logo

小龙虾开发者社区是 CSDN 旗下专注 OpenClaw 生态的官方阵地,聚焦技能开发、插件实践与部署教程,为开发者提供可直接落地的方案、工具与交流平台,助力高效构建与落地 AI 应用

更多推荐