Skip to content

[hipDNN] Add CustomOp descriptor lowering#5575

Open
IanWood1 wants to merge 1 commit intoROCm:developfrom
IanWood1:custom_op_pt2
Open

[hipDNN] Add CustomOp descriptor lowering#5575
IanWood1 wants to merge 1 commit intoROCm:developfrom
IanWood1:custom_op_pt2

Conversation

@IanWood1
Copy link
Member

@IanWood1 IanWood1 commented Mar 18, 2026

Motivation

Adds descriptor-based lowering support for the CustomOp operation in hipDNN. This enables custom ops to be lowered through the descriptor API path (HIPDNN_USE_DESCRIPTOR_API=1), creating backend operation descriptors that serialize to FlatBuffer graphs.

Technical Details

Added descriptor-based lowering for the CustomOp operation:

  • Backend descriptor (CustomOpOperationDescriptor) with setAttribute/getAttribute/finalize/buildNode supporting variable-length input/output tensor arrays, a plugin identifier string (custom_op_id), an opaque byte payload, and compute data type
  • Frontend packer (CustomOpPacker.hpp) bridging frontend CustomOpAttributes to backend descriptors
  • create_operation() override in CustomOpNode.hpp
  • 5 new backend attribute enums (3000-3004) with _EXT suffix
  • New backend descriptor type HIPDNN_BACKEND_OPERATION_CUSTOM_OP_DESCRIPTOR_EXT
  • New shared helpers setByteArray/getByteArray in DescriptorAttributeUtils for opaque byte payloads
  • Shared test constants in CustomOpConstants.hpp

Files Added

  • CustomOpOperationDescriptor.hpp/.cpp — Backend descriptor with setAttribute/getAttribute/finalize/buildNode
  • CustomOpPacker.hpp — Frontend packer bridging frontend attributes to backend descriptors
  • CustomOpConstants.hpp — Shared test constants in test_sdk
  • Unit tests, graph tests, integration tests for full round-trip verification

Files Modified

  • Backend enums (descriptor type, attribute names — all with _EXT suffix)
  • Descriptor factory, string utils
  • DescriptorAttributeUtils (new setByteArray/getByteArray helpers)
  • Frontend CustomOpNode (create_operation override)
  • CMakeLists.txt (backend src, backend tests, frontend tests)

Test Plan

  • Backend unit tests (descriptor lifecycle, finalize validation, attribute set/get error paths, buildNode with multiple compute types)
  • Backend graph tests (serialization round-trip)
  • Frontend integration tests (full pipeline: frontend graph → descriptor lowering → serialize → deserialize → verify, including auto-assigned UID preservation)

Adds descriptor-based lowering support for the CustomOp operation in
hipDNN. This enables custom ops to be lowered through the descriptor
API path (`HIPDNN_USE_DESCRIPTOR_API=1`), creating backend operation
descriptors that serialize to FlatBuffer graphs.

This is required ahead of ROCm#4782 (Remove FlatBuffers from frontend
public API), which will make descriptor-based lowering the only path.
Without this, CustomOp (added in ROCm#5341) would break once the direct
FlatBuffer serialization path is removed.

Added descriptor-based lowering for the CustomOp operation:
- Backend descriptor (`CustomOpOperationDescriptor`) with
  setAttribute/getAttribute/finalize/buildNode supporting variable-length
  input/output tensor arrays, a plugin identifier string (custom_op_id),
  an opaque byte payload, and compute data type
- Frontend packer (`CustomOpPacker.hpp`) bridging frontend
  `CustomOpAttributes` to backend descriptors
- `create_operation()` override in `CustomOpNode.hpp`
- 5 new backend attribute enums (3000-3004) with `_EXT` suffix
- New backend descriptor type
  `HIPDNN_BACKEND_OPERATION_CUSTOM_OP_DESCRIPTOR_EXT = 28`
- New shared helpers `setByteArray`/`getByteArray` in
  DescriptorAttributeUtils for opaque byte payloads
- Shared test constants in `CustomOpConstants.hpp`
- Comprehensive tests: backend unit tests, graph round-trip tests,
  frontend integration tests

- `CustomOpOperationDescriptor.hpp/.cpp` — Backend descriptor with
  setAttribute/getAttribute/finalize/buildNode
- `CustomOpPacker.hpp` — Frontend packer bridging frontend attributes
  to backend descriptors
- `CustomOpConstants.hpp` — Shared test constants in test_sdk
- Unit tests, graph tests, integration tests for full round-trip
  verification

- Backend enums (descriptor type, attribute names — all with `_EXT`
  suffix)
- Descriptor factory, string utils
- DescriptorAttributeUtils (new setByteArray/getByteArray helpers)
- Frontend CustomOpNode (create_operation override)
- CMakeLists.txt (backend src, backend tests, frontend tests)

- [x] Backend unit tests (descriptor lifecycle, finalize validation,
  attribute set/get error paths, buildNode with multiple compute types)
- [x] Backend graph tests (serialization round-trip)
- [x] Frontend integration tests (full pipeline: frontend graph →
  descriptor lowering → serialize → deserialize → verify, including
  auto-assigned UID preservation)
@IanWood1 IanWood1 marked this pull request as ready for review March 18, 2026 23:44
@IanWood1 IanWood1 requested a review from a team as a code owner March 18, 2026 23:44
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 92.63566% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../include/hipdnn_frontend/detail/CustomOpPacker.hpp 71.05% 3 Missing and 8 partials ⚠️
...nd/src/descriptors/CustomOpOperationDescriptor.cpp 97.48% 3 Missing and 1 partial ⚠️
...ckend/src/descriptors/DescriptorAttributeUtils.cpp 87.10% 0 Missing and 4 partials ⚠️

❌ Your project status has failed because the head coverage (77.21%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5575      +/-   ##
===========================================
+ Coverage    67.29%   67.32%   +0.03%     
===========================================
  Files         1847     1850       +3     
  Lines       284305   284563     +258     
  Branches     39882    39924      +42     
===========================================
+ Hits        191308   191577     +269     
+ Misses       76523    76496      -27     
- Partials     16474    16490      +16     
Flag Coverage Δ *Carryforward flag
hipBLAS 90.67% <ø> (ø) Carriedforward from 1151d09
hipBLASLt 43.49% <ø> (ø) Carriedforward from 1151d09
hipCUB 82.21% <ø> (ø) Carriedforward from 1151d09
hipDNN 85.32% <92.64%> (+0.15%) ⬆️
hipFFT 55.59% <ø> (ø) Carriedforward from 1151d09
hipRAND 76.12% <ø> (ø) Carriedforward from 1151d09
hipSOLVER 68.81% <ø> (ø) Carriedforward from 1151d09
hipSPARSE 84.70% <ø> (ø) Carriedforward from 1151d09
rocBLAS 47.97% <ø> (ø) Carriedforward from 1151d09
rocFFT 53.24% <ø> (ø) Carriedforward from 1151d09
rocRAND 57.07% <ø> (ø) Carriedforward from 1151d09
rocSOLVER 77.21% <ø> (ø) Carriedforward from 1151d09
rocSPARSE 71.48% <ø> (ø) Carriedforward from 1151d09

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...ects/hipdnn/backend/src/BackendEnumStringUtils.hpp 99.74% <100.00%> (+<0.01%) ⬆️
...nd/src/descriptors/CustomOpOperationDescriptor.hpp 100.00% <100.00%> (ø)
...ckend/src/descriptors/DescriptorAttributeUtils.hpp 91.26% <ø> (ø)
...pdnn/backend/src/descriptors/DescriptorFactory.cpp 96.12% <100.00%> (+0.12%) ⬆️
...tend/include/hipdnn_frontend/node/CustomOpNode.hpp 95.05% <100.00%> (+0.15%) ⬆️
...nd/src/descriptors/CustomOpOperationDescriptor.cpp 97.48% <97.48%> (ø)
...ckend/src/descriptors/DescriptorAttributeUtils.cpp 93.25% <87.10%> (+1.33%) ⬆️
.../include/hipdnn_frontend/detail/CustomOpPacker.hpp 71.05% <71.05%> (ø)

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants