pypto-case-norm-batchnorm

pypto-case-norm-batchnorm is a skill for Claude Code, Codex from mindspore-ai/akg. It costs 41 tokens per session (719 once invoked), scanned A, original, Apache-2.0.

A PyPTO example of BatchNorm, a method that normalizes values using statistics calculated across a batch and spatial positions. It reshapes the input to three dimensions and processes channels in groups.

In plain words
What is it for?
Use it as a pattern for a 3D BatchNorm kernel with channel loops, multi-axis sums, normalization, and broadcasting.
Why use it?
It demonstrates how to calculate sums and squared sums over multiple axes, then broadcast the resulting statistics back across the data.

Skill for Claude CodeCodex

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

Good fit Use it as a pattern for a 3D BatchNorm kernel with channel loops, multi-axis sums, normalization, and broadcasting.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mindspore-ai/akg/pypto-case-norm-batchnorm
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-case-norm-batchnorm
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-case-norm-batchnorm

README.md
[![agentmods](https://agentmods.dev/badge/skills/mindspore-ai/akg/pypto-case-norm-batchnorm/github.svg)](https://agentmods.dev/skills/mindspore-ai/akg/pypto-case-norm-batchnorm)
Your own site
<a href="https://agentmods.dev/skills/mindspore-ai/akg/pypto-case-norm-batchnorm"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/pypto-case-norm-batchnorm/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-case-norm-batchnorm

Your own site · 80×15
<a href="https://agentmods.dev/skills/mindspore-ai/akg/pypto-case-norm-batchnorm"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/pypto-case-norm-batchnorm.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 41 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 719 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.00041 $0.00719
Opus 5 $0.00020 $0.00360
Sonnet 5 $0.00008 $0.00144
Haiku 4.5 $0.00004 $0.00072

Measured 10d ago against content hash becf8404ecc2, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

pypto-case-norm-batchnorm 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 10d 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/cases/pypto-case-norm-batchnorm/SKILL.md · 56 lines

What it actually says

模式 C-2:3D Norm — BatchNorm

forward 中 reshape(B, C, -1) 降为 3D,kernel 沿 channel 维 loop。

BASIC_CHANNEL = 8
MAIN_CHANNEL_LOOP = 8   # channels / BASIC_CHANNEL

def create_batchnorm_kernel(batch, channels, spatial, eps):
    assert channels == MAIN_CHANNEL_LOOP * BASIC_CHANNEL
    @pypto.frontend.jit(runtime_options=..., debug_options=...)
    def kernel(
        x: pypto.Tensor((batch, channels, spatial), pypto.DT_FP32),
    ) -> pypto.Tensor((batch, channels, spatial), pypto.DT_FP32):
        output = pypto.tensor([batch, channels, spatial], pypto.DT_FP32)
        inv_total = 1.0 / (batch * spatial)
        pypto.set_vec_tile_shapes(1, 1, 16384)
        for ci in pypto.loop(0, MAIN_CHANNEL_LOOP, 1, name="LOOP_CH", idx_name="ci"):
            ch_off = ci * BASIC_CHANNEL
            x_chunk = pypto.view(x, [batch, BASIC_CHANNEL, spatial], [0, ch_off, 0])
            # 多轴归约:连续两次单轴 sum
            s = pypto.sum(x_chunk, dim=2, keepdim=True)
            s = pypto.sum(s, dim=0, keepdim=True)      # (1, C, 1)
            sq = pypto.sum(x_chunk * x_chunk, dim=2, keepdim=True)
            sq = pypto.sum(sq, dim=0, keepdim=True)
            mean = s * inv_total
            var = sq * inv_total - mean * mean
            denom = pypto.sqrt(var + eps)
            # expand_clone 广播回 batch 维
            mean_b = pypto.expand_clone(mean, [batch, BASIC_CHANNEL, 1])
            denom_b = pypto.expand_clone(denom, [batch, BASIC_CHANNEL, 1])
            normed = (x_chunk - mean_b) / denom_b
            pypto.assemble(normed, [0, ch_off, 0], output)
        return output
    return kernel

forward:reshape(B, C, -1) → kernel → reshape(x.shape) RMSNorm 同模式:3D (B, features, spatial),只求 sqrt(mean(x²) + eps) 无需减均值。

模式要点

  • pypto.sum(dim=2)pypto.sum(dim=0) — 多轴归约必须分步
  • pypto.expand_clone(mean, [B, C, 1]) — 单轴广播,归约后恢复维度用于运算
  • set_vec_tile_shapes(1, 1, 16384) — 3D,前两维小,最后维大 tile
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. 10d ago First seen · 56 lines · 41 tokens per session scan A becf8404ecc2

Subscribe to this mod's changes

pypto-case-norm-batchnorm is a skill published in the GitHub repository mindspore-ai/akg (259 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 41 tokens to every session and 719 once invoked, about $0.0002 per session on Opus 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.