pypto-loop-view

pypto-loop-view is a skill for Claude Code, Codex from mindspore-ai/akg. It costs 43 tokens per session (1,297 once invoked), scanned A, original, Apache-2.0.

A rulebook for using PyPTO loops and views when view shapes must be known during compilation. A view is a different way of interpreting part of a tensor without changing its data.

In plain words
What is it for?
Use it to split tensors into looped chunks, choose batch sizes that divide the input, and assemble processed chunks back into an output tensor without invalid view shapes.
Why use it?
Using a runtime loop value as a view size can cause a compile-time error, so the guide shows safe fixed-size chunking patterns.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to split tensors into looped chunks, choose batch sizes that divide the input, and assemble processed chunks back into an output tensor without invalid view shapes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mindspore-ai/akg/pypto-loop-view
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mindspore-ai/akg --skill pypto-loop-view
Clone the repo
git clone --depth 1 https://github.com/mindspore-ai/akg

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pypto-loop-view

README.md
[![agentmods](https://agentmods.dev/badge/skills/mindspore-ai/akg/pypto-loop-view/github.svg)](https://agentmods.dev/skills/mindspore-ai/akg/pypto-loop-view)
Your own site
<a href="https://agentmods.dev/skills/mindspore-ai/akg/pypto-loop-view"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/pypto-loop-view/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pypto-loop-view

Your own site · 80×15
<a href="https://agentmods.dev/skills/mindspore-ai/akg/pypto-loop-view"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/pypto-loop-view.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,297 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00043 $0.01297
Opus 5.5 $0.00017 $0.00519
Sonnet 5.5 $0.00009 $0.00259
Haiku 4.5 $0.00004 $0.00130

Measured 3mo ago against content hash 07ff79e832b3, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pypto-loop-view scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

akg_agents/python/akg_agents/op/resources/skills/pypto/guides/pypto-loop-view/SKILL.md · 124 lines

How it starts

The opening of the file, as written. The whole thing — 124 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Loop + View:编译期常量规则

致命错误:ValueError: Not concrete value

最常见的首次生成错误。所有 pypto.view 的 shape 参数必须是编译期常量(字面量或闭包变量)。

# WRONG — min() 含 loop 变量 offset,是运行时值
for idx in pypto.loop(0, num_iters, 1, ...):
    offset = idx * BASIC_BATCH
    current = min(BASIC_BATCH, total_size - offset)      # runtime!
    chunk = pypto.view(x, [current, n], [offset, 0])     # ValueError!

任何含 loop idx 的表达式都是运行时值,不能用于 view shape。

通用正确写法

方法 A:确保整除(推荐)

选择 BASIC_BATCH 使 total_size 可整除,或在 forward 中 assert 整除性:

def create_kernel(total_rows, cols, basic_batch):
    assert total_rows % basic_batch == 0
    num_iters = total_rows // basic_batch  # 闭包常量

    @pypto.frontend.jit(...)
    def kernel(x: pypto.Tensor((total_rows, cols), ...)) -> ...:
        output = pypto.tensor([total_rows, cols], pypto.DT_FP32)
        pypto.set_vec_tile_shapes(1, 8192)
        for idx in pypto.loop(0, num_iters, 1, name="LOOP", idx_name="idx"):
            off = idx * basic_batch
            chunk = pypto.view(x, [basic_batch, cols], [off, 0])
            result_chunk = chunk * 2.0  # 示例操作
            pypto.assemble(result_chunk, [off, 0], output)
        return output
    return kernel

class ModelNew(torch.nn.Module):
    def forward(self, x):
        total_rows = x.shape[0] * x.shape[1]
        # 调参由 loop_count 空间驱动:先试 16/32,再反推 basic_batch
        target_loop_count = 16
        assert total_rows % target_loop_count == 0
        basic_batch = total_rows // target_loop_count
        ...

方法 B:主循环 + 尾部

当无法保证整除时:

def create_kernel(total_rows, cols, basic_batch):
    full_iterations = total_rows // basic_batch
    tail = total_rows % basic_batch
    tail_offset = full_iterations * basic_batch
    # full_iterations, tail, tail_offset 都是闭包常量

    @pypto.frontend.jit(...)
    def kernel(x: pypto.Tensor((total_rows, cols), ...)) -> ...:
        output = pypto.tensor([total_rows, cols], pypto.DT_FP32)
        pypto.set_vec_tile_shapes(1, 8192)

        for idx in pypto.loop(0, full_iterations, 1, name="LOOP", idx_name="idx"):
            off = idx * basic_batch
            chunk = pypto.view(x, [basic_batch, cols], [off, 0])
            pypto.assemble(chunk * 2.0, [off, 0], output)

        if tail > 0:  # 编译期求值(tail 是闭包常量)
            tail_chunk = pypto.view(x, [tail, cols], [tail_offset, 0])
            pypto.assemble(tail_chunk * 2.0, [tail_offset, 0], output)
        return output
    return kernel

Read the full file on GitHub · 124 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 124 lines · 43 tokens per session scan A 07ff79e832b3

Subscribe to this mod's changes

pypto-loop-view is a skill published in the GitHub repository mindspore-ai/akg (269 stars, last pushed yesterday), licensed Apache-2.0. It adds 43 tokens to every session and 1,297 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

pypto-loop-view compared with skills from other repositories

pypto-loop-view next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
pypto-loop-viewmindspore-ai/akgSkill269yesterdayApache-2.0A43Claude Code, Codex
ai-loopsickn33/agentic-awesome-skillsSkill51ktodayMITA28Claude Code
software-implementationstencila/stencilaSkill916todayApache-2.0A124Claude Code
project-executionathola/claude-night-marketSkill358yesterdayMITA31Claude Code
architecture-paradigmsathola/claude-night-marketSkill358yesterdayMITA27Claude Code
algolia-search-v2diegosouzapw/awesome-omni-skillsSkill1814d agoMITA50Claude Code, Codex
notion-spec-to-implementationseaworld008/Commonly-used-high-value-skillsSkill756d agoMITA38Codex