rocm/rocm-libraries/hipdnn-codegen
Claude Code and agent skill by rocm/rocm-libraries
- community
Checking that the SKILL.md file is still in the repository.
Generate hipDNN operation boilerplate from a YAML config. Use when the user wants to add a new operation type to hipDNN, or generate descriptor/packer/unpacker code.
Install
npx vskill@latest install rocm/rocm-libraries/hipdnn-codegenSKILL.md
The same SKILL.md was published earlier as rocm/rocm-libraries/hipdnn-codegen.
hipDNN Code Generator Skill
Generate all boilerplate code needed to add a new operation to hipDNN from a YAML config.
This skill is near-autonomous. The agent first tries to resolve everything itself by deriving from the schema, the existing codebase, and cudnn-frontend on GitHub. It may prompt the user as a fallback on three classes of decision where derivation has failed:
- cuDNN naming uncertainty — when the cuDNN equivalent descriptor / attribute / frontend-node name cannot be confidently identified after consulting
cudnn-frontend(drives the_EXTdecision; see Step 3a-i). - `infer_properties_node()` strategy — output-shape inference rule, when the op's shape behavior isn't obvious from analogous ops.
- `pre_validate_node()` rules — additional validation beyond default null/dim checks, when domain-specific constraints aren't derivable.
In a clean, well-known op (cuDNN-aligned with a clear analog), the agent may not prompt at all on the three classes above.
There are two mandatory prompts:
- Schema confirmation (Step 2a-ii), whenever the agent had to construct the FBS schema (from a user description, or from
cudnn-frontend). Schema mistakes propagate through every layer, so the agent must show the schema and get explicit user sign-off before continuing. This prompt is skipped only when the user supplied a complete FBS file. - Work-model confirmation (Step 11, Class C), whenever the op has no
logicalFlopsdecision inEngineFeatures.hppyet: the FLOP formula, or "no counting convention" with a reason, and which operands are content-dependent (work_data_dependent). A missing or wrong answer degrades UHD heuristics without any build or test failure (nograph.flops, or a count that is not the declared problem's), so the agent proposes its derivation and gets explicit sign-off.
Everything else is mechanical and is derived from the FBS schema, existing codebase state, and the conventions in this skill.
For human-facing context, including the cuDNN parity rules, layer-by-layer reference, testing matrix, and PR checklist, see `projects/hipdnn/docs/AddingNewOperations.md`. For a complete worked example, see `configs/convolution_fwd.yaml`.
Philosophy
You MUST run the generator. The code generator exists to produce correct, pattern-matched boilerplate. Do not skip it and write code by hand — even if you think you understand the patterns well enough. The generator's output is the starting point for every file and fragment. If Bash access is unavailable or denied, stop and ask the user to grant it rather than proceeding without the generator.
After running the generator, the agent owns the integration. Generated output is scaffolding, not a finished product. Before placing any generated file or inserting any fragment, check if the target already exists in hipDNN. If it does, compare the generated version with the existing code. Use whichever is more correct, or merge them if each covers different parts. If a fragment's insertion point has changed, adapt the fragment to the current code structure.
Generated code is not always perfect. Enum value numbering may differ between the backend C-API, SDK, and frontend — use frontend_value and sdk_name overrides in enum_def to handle mismatches. Test patterns may need adjustment for unusual field types. Fragment insertion points are guidelines; always read the target file. But these are adjustments to generator output, not reasons to bypass the generator entirely.
The goal is a clean, building, tested integration. If generated code needs tweaks to compile, make them. If a fragment conflicts with existing code, resolve it. Judgment and adaptation are applied to generated output, not as a substitute for it.
When to Use Which Mode
| Scenario | Mode | |
|---|---|---|
| Brand new operation (nothing exists yet) | full | |
| Adding backend only (frontend exists or will land later) | backend | |
| Adding frontend only (backend descriptor already exists) | frontend |
Arguments
$ARGUMENTScan contain:- Schema or operation: Path to
.fbsschema file, path to existing YAML config, or operation name (e.g.,convolution_fwd) - Mode (one of):
backend(default) - Descriptor, Packer, Unpacker + backend testsfrontend- Node, Attributes, Graph method + frontend testsfull- Everything (backend + frontend)
Directory Locations
Determine the hipDNN project root by finding the nearest parent directory containing tools/DescriptorGenerator/. Set paths relative to that:
Hint: if the current working directory is inside a rocm-libraries worktree, the hipDNN root is at <worktree>/projects/hipdnn/. If invoked from a standalone hipDNN checkout, it is the repo root.
Execution Steps
1. Parse Arguments and Set Up
Parse $ARGUMENTS for:
- Schema path, config path, or operation name
- Mode (default:
backend)
Locate the hipDNN project root. Verify the codegen venv exists:
2. Determine Input Type
- If argument is a
.fbsfile path: proceed to Step 3 (create YAML config from schema) - If argument is a
.yamlfile path: skip to Step 5 (run generator) - If argument is an operation name and
configs/<name>.yamlexists: skip to Step 5 - If argument is an operation name and no FBS schema exists for it: proceed to Step 2a (author the FBS schema)
- If the argument is unrecognized or ambiguous: ask the user to clarify
2a. Author the FBS Schema (if it does not exist)
Schemas live ONLY in $HIPDNN_SRC/flatbuffers_sdk/schemas/ (they were removed from data_sdk/). Before deriving the YAML, you may need to write the FBS schema yourself.
2a-i. Source the schema content
Pick the path that matches what the user provided:
- User provided an FBS file → use it directly, skip to 2a-ii.
- User provided a description (text listing inputs, outputs, attributes, modes) → translate it directly into the table, skip to 2a-ii.
- User gave only an op name → derive the schema from
cudnn-frontendon GitHub:
- Run the directory listing + node-file fetch from Step 3a-i to locate the matching cuDNN node header (e.g.,
include/cudnn_frontend/node/<op>.h). - From that header, find the attributes class it references (e.g.,
Conv_fprop_attributes). Fetch its source — usually underinclude/cudnn_frontend/graph_properties.hor alongside the node header. - Walk the attributes class:
- Each tensor input/output method (typically
set_<name>(...)) becomes a<name>_tensor_uid: long (cache_uid)field (long = null (cache_uid)when optional). Note which are required vs optional. Addwork_data_dependentto the annotation ((cache_uid, work_data_dependent)) when the tensor's contents, not its shape, decide how much work the op does: valid lengths, page tables, block masks, routing offsets. An operand read densely whatever its values (an additive bias, a dropout seed) is not work-data-dependent. Declare each attribute used at file scope (attribute "cache_uid";,attribute "work_data_dependent";). - Each scalar/vector attribute (typically
set_<attr>(...)) becomes a typed field with the matching cuDNN name. - Mode-style enums become a
<field>: <Enum>field; capture the enum members from the cuDNN definition.
- Use the same naming as cuDNN (lowercase snake_case for fields, matching cuDNN attribute identifiers). Apply
_EXTper the rule in Step 3a only to fields with no cuDNN equivalent. - Write the draft schema to
$HIPDNN_SRC/flatbuffers_sdk/schemas/<op_name>_attributes.fbs.
2a-ii. Confirm the schema with the user
When this prompt is required:
| Schema source | Confirmation required? | |
|---|---|---|
| User supplied a complete FBS file | No (they already authored it) | |
| User supplied a description and the agent translated it | Yes | |
Agent derived from cudnn-frontend | Yes |
When required, show the schema and the parsed structure, and get explicit sign-off via AskUserQuestion:
"Here is the FBS schema I will use for<op_name>(sourced from<description / cudnn-frontend URL>):```flatbuffers<full schema contents>```Tensor inputs:<list>. Tensor outputs:<list>. Optional fields:<list>. Mode enums:<list>. Work-data-dependent operands:<list or none>.Confirm before I proceed: is this schema correct? (Yes / Edit-and-resend / No-rewrite)"
Do NOT proceed to 2a-iii until the user confirms. If the user requests edits, apply them and ask again. Schema mistakes propagate to every layer (FBS table, generated headers, descriptor, packer, unpacker, attributes class, node, tests) — fixing them late is expensive.
2a-iii. Wire the schema into the build
Once confirmed:
- Update `graph.fbs`:
- Add
include "<op_name>_attributes.fbs"; - Add
<Op>Attributesto theNodeAttributesunion
- Update the `SCHEMAS` list in
$HIPDNN_SRC/flatbuffers_sdk/CMakeLists.txtso the new schema is compiled into the SDK. - Rebuild the FlatBuffers SDK target so the generated headers are present before the code generator runs:
``bash cd $HIPDNN_SRC/build # or your active build dir ninja hipdnn_flatbuffers_sdk ` (If no build dir exists yet, see [docs/Building.md`](../../../../../docs/Building.md) for first-time setup.)
After 2a-iii, proceed to Step 3.
3. Create YAML Config from FBS Schema
Read the FBS schema file. Map fields to YAML config following these rules:
| FBS Field Pattern | YAML Section | YAML type | |
|---|---|---|---|
*_tensor_uid: long | tensor_fields | (tensors are UIDs) | |
*_tensor_uid: long (cache_uid, work_data_dependent) | tensor_fields, with work_data_dependent: true | (tensors are UIDs) | |
field: [long] | data_fields | vector_int64 | |
field: SomeEnum | data_fields | mode | |
field: float | data_fields | scalar_float | |
field: long (non-UID) | data_fields | scalar_int64 | |
field: bool | data_fields | bool | |
field: [long] (array of UIDs) | tensor_array_fields | (tensor arrays; work_data_dependent as for tensor_fields) |
Derive all config fields from the schema and existing codebase — do NOT ask the user for these. Use existing configs and backend code to determine:
- Operation name: Derive from the FBS table name (e.g.,
ConvolutionFwdAttributes→ConvolutionFwd) - Descriptor type enum: Search
$HIPDNN_SRC/backend/include/HipdnnBackendDescriptorType.hfor existing enum entries - Operation attribute prefix: Search
$HIPDNN_SRC/backend/include/HipdnnBackendAttributeName.hfor existingHIPDNN_ATTR_OPERATION_*entries - Shared attributes: Compare attribute names against existing operations in the codebase
- Compute data type: Check if the FBS schema has compute precision fields; check existing operations for patterns
- Test tensor UIDs: Read existing configs in
$CODEGEN/configs/to find used UID ranges, pick the next available - Frontend fields (graph method name, NodeType, union type): Derive from existing frontend code or operation name conventions
If a field truly cannot be determined, use sensible defaults derived from the operation name. Only ask the user as a last resort for genuinely ambiguous decisions.
Write the config to $CODEGEN/configs/<operation>.yaml.
Use $CODEGEN/configs/convolution_fwd.yaml as the reference template for all config fields.
3a. cuDNN Naming Parity Check (_EXT Decision Rule)
Parity with cuDNN is nominal (names match) but not numeric (values do not align — pick the next free value as Step 3 already does).
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingprojects/hipdnn/tools/DescriptorGenerator/.claude/skills/hipdnn-codegen/SKILL.md
Popularity
- Repository stars
- 441
- Repository forks
- 420
- 7-day trend score
- 30
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/rocm/rocm-libraries/hipdnn-codegen)