mindspore-ai/akg/pypto-case-matvec

Claude Code and agent skill by mindspore-ai/akg

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

矩阵-向量乘法:K > 65535 时用 elementwise mul + sum 替代 matmul

Install

npx vskill@latest install mindspore-ai/akg/pypto-case-matvec

SKILL.md

The same SKILL.md was published earlier as mindspore-ai/akg/pypto-case-matvec.

Matrix-Vector Multiplication (K > 65535)

A: (256, 131072), B: (131072, 1) -> C: (256, 1)

K=131072 超过 pypto.matmul 限制(最后一维 <= 65535),用 sum(a * b_row, dim=1) 替代。

python
def create_matvec_sum_kernel(a_shape, b_shape):
out_shape = (a_shape[0], 1)
@pypto.frontend.jit(...)
def matvec_sum_kernel(
a: pypto.Tensor(a_shape, pypto.DT_FP32),
b_row: pypto.Tensor(b_shape, pypto.DT_FP32),
) -> pypto.Tensor(out_shape, pypto.DT_FP32):
output = pypto.tensor(list(out_shape), pypto.DT_FP32)
pypto.set_vec_tile_shapes(1, 8192)
output[:] = pypto.sum(a * b_row, dim=1, keepdim=True)
return output
return matvec_sum_kernel
class ModelNew(torch.nn.Module):
def forward(self, A, B):
assert A.dim() == 2
assert tuple(A.shape) == (256, 131072)
assert B.dim() == 2
assert tuple(B.shape) == (131072, 1)
A = A.contiguous()
# B: (K, 1) -> (1, K) 用于广播乘法
B_row = B.contiguous().reshape(1, -1)
return create_matvec_sum_kernel(tuple(A.shape), tuple(B_row.shape))(A, B_row)

关键点:forward 中 B.reshape(1, -1) 将列向量转为行向量,使 a * b_row 可广播。

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
259
Repository forks
48
7-day trend score
28

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/mindspore-ai/akg/pypto-case-matvec/badge)](https://verified-skill.com/skills/mindspore-ai/akg/pypto-case-matvec)

Something wrong with this skill or its page? Tell us.