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.
npx agentmods add skills/mindspore-ai/akg/pypto-apinpx skills add mindspore-ai/akg --skill pypto-apigit clone --depth 1 https://github.com/mindspore-ai/akgWrote 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.
[](https://agentmods.dev/skills/mindspore-ai/akg/pypto-api)<a href="https://agentmods.dev/skills/mindspore-ai/akg/pypto-api"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/pypto-api.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00018 | $0.01576 |
| Opus 5 | $0.00009 | $0.00788 |
| Sonnet 5 | $0.00004 | $0.00315 |
| Haiku 4.5 | $0.00002 | $0.00158 |
Grade A, and why
pypto-api 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 6d 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.
How it starts
The opening of the file, as written. The whole thing — 117 lines — stays where its author put it; the contents beside it link to each section on GitHub.
PyPTO API 速查
Kernel 装饰器
@pypto.frontend.jit(
runtime_options={"run_mode": _PYPTO_RUN_MODE},
debug_options={"runtime_debug_mode": _PYPTO_RUNTIME_DEBUG_MODE},
)
def kernel(x: pypto.Tensor(shape_tuple, dtype)) -> pypto.Tensor(shape_tuple, dtype):
...
张量
| API | 用途 | 示例 |
|---|---|---|
pypto.Tensor(shape, dtype) |
输入/输出类型标注 | x: pypto.Tensor((m, k), pypto.DT_FP32) |
pypto.tensor(shape_list, dtype) |
kernel 内创建输出 | output = pypto.tensor([m, n], pypto.DT_FP32) |
pypto.zeros(shape_list, dtype=) |
零初始化张量(累加器) | acc = pypto.zeros([1], dtype=pypto.DT_FP32) |
pypto.full(shape, val, dtype, valid_shape=) |
常量填充张量 | ones = pypto.full(s, 1.0, pypto.DT_FP32, valid_shape=s) |
数据类型:pypto.DT_FP32、pypto.DT_INT32、pypto.DT_INT64(INT64 仅用于输入标注)。
Tile 配置
| API | 约束 |
|---|---|
pypto.set_vec_tile_shapes(*shapes) |
参数个数 = 被操作张量 rank |
pypto.set_cube_tile_shapes(m, k, n, l1, split_k) |
固定 5 参数 |
tile 双约束:
prod(tile_shape)≤ 16384auto_tiles = prod(每维 ceil(shape[i]/tile[i]))≤ 2048(每个 op)
- 必须在任何计算操作之前调用。一个 kernel 内可多次切换 tile。
- 若
auto_tiles > 2048,优先改为loop + view/assemble分块实现。 - vec tile 推荐:
(8192)(1D)、(1, 16384)(2D)、(1, 1, 16384)(3D) - cube tile 推荐:
set_cube_tile_shapes([128, 128], [32, 128], [256, 256], True, False)
分块
| API | 用途 | 约束 |
|---|---|---|
pypto.loop(start, end, step, name=, idx_name=) |
编译期循环 | 不嵌套、尽量少用 |
pypto.view(tensor, shape, offset) |
切片提取(等价 tensor[a:b, c:d]) |
shape 各维为编译期常量,rank 不变,每维 ≤ 输入对应维 |
pypto.assemble(chunk, offset, output) |
写回子块(等价切片赋值) | 无 |
pypto.view 不是 reshape。它是 tensor[offset[0]:offset[0]+shape[0], ...] 的等价 API。不能改变维度数,不能改变维度排布。所有 reshape 必须在 forward 中用 torch 完成。
算术运算
运算符规则:+ * 支持标量在任意位置;- / 要求 tensor 在左侧(1.0 - x crash)。
函数调用:pypto.add/sub/mul/div 第一参数必须 Tensor。
一元取反 -x:不支持,用 pypto.mul(x, -1.0) 或 x * (-1.0)。
切片赋值:output[:] = expr
数学函数
| 函数 | 说明 |
|---|---|
pypto.exp(x) |
指数 |
pypto.log(x) |
对数 |
pypto.sqrt(x) |
平方根 |
pypto.abs(x) |
绝对值 |
pypto.sigmoid(x) |
sigmoid |
pypto.softmax(x, dim=) |
softmax |
pypto.maximum(a, b) |
逐元素最大,b 可以是标量:pypto.maximum(x, 0.0) |
pypto.minimum(a, b) |
逐元素最小,b 可以是标量:pypto.minimum(x, 0.0) |
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.
- 6d ago First seen · 117 lines · 18 tokens per session scan A 48a44a183214
pypto-api is a skill published in the GitHub repository mindspore-ai/akg (259 stars, last pushed 26d ago), licensed Apache-2.0. It adds 18 tokens to every session and 1,576 once invoked, about $0.0001 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.
Other skills, from other repositories
pypto-basics
写 PyPTO 前,先把 baseline forward 变成“可执行语义合同”,再做实现与优化。.
pypto-api
PyPTO 全部 API 签名与约束速查.
matlab
Build, review, migrate, and safely plan MATLAB or GNU Octave numerical workflows, including arrays, tabular/time data, tests, projects, graphics, MAT files, and explicit Python interoperability.
pennylane
Hardware-agnostic quantum ML framework with automatic differentiation. Use when training quantum circuits via gradients, building hybrid quantum-classical models, or needing device portability across IBM/Google/Rigetti/IonQ. Best for variational algorithms (VQE, QAOA), quantum neural networks, and integration with…
dd-code-generation
Use pup CLI for immediate Datadog operations or generate code for integration into applications.
typing-exclusion-worker
Python typing exclusion worker: remove assigned mypy exclusion modules in small scoped batches, fix typing issues, run validation, and produce a structured completion summary. Use when running parallel typing-debt workers or when asked to remove modules from pyproject mypy exclusion overrides.