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/cpu-basicsnpx skills add mindspore-ai/akg --skill cpu-basicsgit 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/cpu-basics)<a href="https://agentmods.dev/skills/mindspore-ai/akg/cpu-basics"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/cpu-basics.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.00031 | $0.04040 |
| Opus 5 | $0.00015 | $0.02020 |
| Sonnet 5 | $0.00006 | $0.00808 |
| Haiku 4.5 | $0.00003 | $0.00404 |
Grade A, and why
cpu-basics 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 5d 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 — 428 lines — stays where its author put it; the contents beside it link to each section on GitHub.
CPU C++ 编程基础
1. 核心概念
内核 (Kernel)
- 定义: 使用
PYBIND11_MODULE注册的 C++ 函数,编译后在 CPU 上执行 - 特点: 直接操作张量数据指针,支持多种数据类型
- 形式: 使用 PyTorch C++ 扩展,通过
load_inline动态编译加载
张量处理
- 连续性: 确保张量内存布局连续,避免非连续访问
- 类型统一: 内部计算使用统一类型(优先 float32/float64/int32/int64),最后转换回原类型
- 边界检查: 所有数组访问前必须检查边界
内存管理
- 自动管理: PyTorch 自动管理张量内存生命周期
- 指针操作: 直接操作数据指针进行高效计算
- 类型安全: 确保指针类型与张量类型匹配
2. 标准内核结构(五步模式)
所有 CPU C++ 内核都遵循相同的五步结构模式:
torch::Tensor standard_kernel(torch::Tensor x) {
// 1. 确保输入张量是连续的
if (!x.is_contiguous()) {
x = x.contiguous();
}
// 2. 检查数据类型,支持多种类型
torch::ScalarType dtype = x.scalar_type();
bool need_convert = (dtype != torch::kFloat32 && dtype != torch::kFloat64 &&
dtype != torch::kInt32 && dtype != torch::kInt64);
torch::Tensor input = need_convert ? x.to(torch::kFloat32) : x;
// 3. 创建输出张量
torch::Tensor output = torch::zeros_like(input);
// 4. 根据数据类型分发计算
if (input.scalar_type() == torch::kFloat32) {
auto x_ptr = input.data_ptr<float>();
auto out_ptr = output.data_ptr<float>();
int64_t numel = input.numel();
for (int64_t i = 0; i < numel; ++i) {
out_ptr[i] = std::max(0.0f, x_ptr[i]); // ReLU: max(0, x)
}
} else if (input.scalar_type() == torch::kFloat64) {
auto x_ptr = input.data_ptr<double>();
auto out_ptr = output.data_ptr<double>();
int64_t numel = input.numel();
for (int64_t i = 0; i < numel; ++i) {
out_ptr[i] = std::max(0.0, x_ptr[i]);
}
} else if (input.scalar_type() == torch::kInt32) {
auto x_ptr = input.data_ptr<int32_t>();
auto out_ptr = output.data_ptr<int32_t>();
int64_t numel = input.numel();
for (int64_t i = 0; i < numel; ++i) {
out_ptr[i] = std::max(0, x_ptr[i]);
}
} else if (input.scalar_type() == torch::kInt64) {
auto x_ptr = input.data_ptr<int64_t>();
auto out_ptr = output.data_ptr<int64_t>();
int64_t numel = input.numel();
for (int64_t i = 0; i < numel; ++i) {
out_ptr[i] = std::max(0L, x_ptr[i]);
}
}
// 5. 转换回原类型
if (need_convert) {
output = output.to(dtype);
}
return output;
}
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.
- 5d ago First seen · 428 lines · 31 tokens per session scan A 446e70fb89e3
cpu-basics is a skill published in the GitHub repository mindspore-ai/akg (259 stars, last pushed 25d ago), licensed Apache-2.0. It adds 31 tokens to every session and 4,040 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.
Other skills, from other repositories
stock-analysis
Analyze stocks with fundamental and technical analysis. Supports US, China A-shares, and Hong Kong markets. Generate investment reports with key metrics.
fundamental-analyst
基本面分析师,基于财务指标与报表输出结构化财务健康度和估值分析。.
cpu-basics
CPU C++ 算子核心概念、标准结构模式、KernelBench 代码规范和内嵌扩展方法.
tilelang-cuda-api
TileLang CUDA API 完整参考手册,适用于需要查阅具体 API 用法、了解函数参数含义的任意 TileLang CUDA 内核代码生成场景.
tilelang-cuda-basics
TileLang CUDA 核心概念、内核结构和标准编程模式.
pypto-basics
写 PyPTO 前,先把 baseline forward 变成“可执行语义合同”,再做实现与优化。.