cpu-basics

Teach C++ CPU kernel design for PyTorch extensions with memory safety.

6|1|Updated Apr 19, 2026
One-click install
npx skills add https://github.com/xchang1121/AutoResearch-CC-hook --skill cpu-basics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpu-basics
Source: https://github.com/xchang1121/AutoResearch-CC-hook/tree/main/skills/cpp/guides/cpu-basics
Command: npx skills add https://github.com/xchang1121/AutoResearch-CC-hook --skill cpu-basics

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a clear, practical guide to building CPU-based operator kernels in C++ for PyTorch, covering core concepts, safe memory handling, and standardized patterns to accelerate development.

Core Features & Use Cases

  • Core concepts: kernels, tensor handling, memory management, and safety checks.
  • Standard structure: five-step kernel pattern, type handling, and inline C++ extensions.
  • Use cases: creating portable CPU kernels for production-grade ML workloads.

Quick Start

Run through the CPU basics guide to implement a minimal CPU kernel following the five-step pattern.

Frequently Asked Questions about cpu-basics

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a CPU kernel for PyTorch extensions in C++?

To write a CPU kernel for PyTorch extensions, follow a standardized five-step C++ pattern covering tensor handling, type support, and memory-safe boundary checks to build portable operators for ML workflows.

What is tensor contiguity and how do I handle it in CPU kernels?

Tensor contiguity in CPU kernels refers to how tensor data is laid out in memory. You must check and handle contiguity to ensure safe memory access and prevent data misalignment when executing C++ kernel operations across x86_64 and aarch64.

How do I support multiple data types like float32 and int64 in custom PyTorch CPU kernels?

Supporting multiple data types like float32 and int64 in custom PyTorch CPU kernels requires implementing type handling within your C++ extension. This ensures your kernel can process diverse tensor inputs safely across different ML workflows.

Can I use OpenMP for parallel processing in PyTorch C++ CPU kernels?

Yes, you can use OpenMP for parallel processing in PyTorch C++ CPU kernels. There are specific usage rules to follow that ensure safe and fast execution when building portable, memory-safe kernel modules for production environments.

What are the best practices for memory safety in CPU kernel development?

Best practices for memory safety in CPU kernel development include implementing safe boundary checks, managing tensor contiguity, and following a standardized five-step pattern to prevent memory access violations in C++ extensions.

Does this CPU kernel pattern work on both x86_64 and aarch64 architectures?

Yes, this CPU kernel pattern works on both x86_64 and aarch64 architectures. It is designed to create portable, memory-safe C++ kernel modules that operate reliably across different hardware platforms in ML workflows.