Skip to content

[hipDNN] Add CustomOp descriptor lifting#5885

Merged
SamuelReeder merged 21 commits intodevelopfrom
users/sareeder/almiopen-1625/add-custom-op-lifting
Mar 30, 2026
Merged

[hipDNN] Add CustomOp descriptor lifting#5885
SamuelReeder merged 21 commits intodevelopfrom
users/sareeder/almiopen-1625/add-custom-op-lifting

Conversation

@SamuelReeder
Copy link
Copy Markdown
Contributor

@SamuelReeder SamuelReeder commented Mar 26, 2026

Motivation

Adds descriptor-based lifting support for the CustomOp operation, enabling reconstruction of frontend graph attributes from serialized FlatBuffer data. This completes the round-trip path: frontend graph → descriptor lowering → serialize → deserialize → descriptor lifting → frontend graph.

Technical Details

Added fromNode() static factory method to CustomOpOperationDescriptor that reconstructs descriptor state from FlatBuffer NodeT data, resolving tensor UIDs from the shared tensor map. Added HIPDNN_ATTR_OPERATION_NAME_EXT and HIPDNN_ATTR_OPERATION_TYPE_EXT attribute support to setAttribute()/getAttribute(). Created CustomOpUnpacker.hpp that unpacks tensor arrays, byte arrays (opaque buffer), compute data type, and operation name from the C-API descriptor.

Note: updated the CustomOpOperationDescriptor to allow finalization with 0 inputs or outputs on the descriptor. This matches the frontend, but there was inconsistency in the backend.

Test Plan

  • 13 fromNode round-trip unit tests (lifecycle, tensor references, data fields, name preservation, missing tensor failures)
  • 3 name preservation tests in TestGraphDescriptorCustomOp
  • 4 integration lifting tests including AutoAssignedUidsPreservedInRoundTrip
  • TestOperationUnpacker case for CustomOp
  • Shared test constants used throughout

Submission Checklist

Implement the lifting (deserialization) path for the CustomOp operation
descriptor, enabling round-trip serialization through FlatBuffer and
C-API routes.

Backend changes:
- Add fromNode() static factory to CustomOpOperationDescriptor for
  FlatBuffer-based reconstruction
- Add HIPDNN_ATTR_OPERATION_NAME_EXT support to setAttribute/getAttribute
- Add HIPDNN_ATTR_OPERATION_TYPE_EXT support to getAttribute
- Uncomment CustomOp case in NodeFactory

Frontend changes:
- Create CustomOpUnpacker.hpp with helpers for tensor array unpacking,
  byte array unpacking, and full custom op operation unpacking
- Wire unpack_from_descriptor() override in CustomOpNode
- Uncomment CustomOp case in OperationUnpacker

Tests:
- Add TestCustomOpOperationFromNode unit tests (13 test cases)
- Add TestGraphDescriptorCustomOp name preservation tests (3 test cases)
- Add IntegrationCustomOpDescriptorLifting tests (4 test cases)
- Uncomment TestOperationUnpacker CustomOp test case

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SamuelReeder and others added 7 commits March 26, 2026 19:20
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Move unpackAndRegisterTensorArray and getDescriptorAttrByteArray from
CustomOpUnpacker.hpp to DescriptorUnpackHelpers.hpp so they can be
reused by other unpackers. Replace the inline peer_stats unpacking
in BatchnormUnpacker.hpp with a call to the shared helper.

Fix OperationNamePreservedInGraph test to actually test name
preservation through the C-API path (setAttribute before finalize,
then verify via serialized graph). Add OperationNameRoundTripThroughLifting
test that verifies names survive FlatBuffer serialize/deserialize and
NodeFactory rebuild. Remove fromNode-based tests from the graph
descriptor test file (those belong in the fromNode test file).

Add fromNode test variations for different tensor array sizes:
FromNodeWithSingleInputAndOutput (1 in, 1 out) and
FromNodeWithTwoOutputs (2 in, 2 out).

Add SingleInputTwoOutputsRoundTrip integration test to verify
the full lower/lift cycle with non-standard tensor counts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Add tensor dims/strides constants to CustomOpConstants.hpp and use them
throughout the test fixture instead of inline values. Add
SetsTensorReferencesWithFullValues test to verify dims, strides, and
data_type on descriptor objects. Enhance GetAttributeWorksAfterFromNode
to retrieve and verify input/output tensor descriptors via getAttribute
using ScopedDescriptor and verifyTensorDescriptor utility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rray

Cover both new helper functions that were moved to DescriptorUnpackHelpers.hpp.
Six test cases for unpackAndRegisterTensorArray (new tensors, existing reuse,
empty array, count failure, null descriptor, UID query failure) and five for
getDescriptorAttrByteArray (success, not-supported, zero count, count failure,
data failure).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 90.25974% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...nclude/hipdnn_frontend/detail/CustomOpUnpacker.hpp 75.00% 3 Missing and 6 partials ⚠️
.../include/hipdnn_frontend/detail/CustomOpPacker.hpp 81.82% 0 Missing and 4 partials ⚠️
...nd/src/descriptors/CustomOpOperationDescriptor.cpp 98.00% 0 Missing and 1 partial ⚠️
...tend/include/hipdnn_frontend/node/CustomOpNode.hpp 83.33% 0 Missing and 1 partial ⚠️

❌ Your project status has failed because the head coverage (77.72%) 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    #5885      +/-   ##
===========================================
+ Coverage    67.23%   67.52%   +0.29%     
===========================================
  Files         1876     1877       +1     
  Lines       291079   291201     +122     
  Branches     41055    41070      +15     
===========================================
+ Hits        195690   196620     +930     
+ Misses       78592    77733     -859     
- Partials     16797    16848      +51     
Flag Coverage Δ *Carryforward flag
hipBLAS 90.67% <ø> (ø) Carriedforward from be27fb1
hipBLASLt 43.47% <ø> (ø) Carriedforward from be27fb1
hipCUB 82.21% <ø> (ø) Carriedforward from be27fb1
hipDNN 86.23% <90.26%> (+0.06%) ⬆️
hipFFT 54.97% <ø> (-1.58%) ⬇️ Carriedforward from be27fb1
hipRAND 76.12% <ø> (ø) Carriedforward from be27fb1
hipSOLVER 68.73% <ø> (ø) Carriedforward from be27fb1
hipSPARSE 84.70% <ø> (ø) Carriedforward from be27fb1
rocBLAS 47.97% <ø> (ø) Carriedforward from be27fb1
rocFFT 50.06% <ø> (+2.79%) ⬆️ Carriedforward from be27fb1
rocRAND 57.07% <ø> (ø) Carriedforward from be27fb1
rocSOLVER 77.72% <ø> (ø) Carriedforward from be27fb1
rocSPARSE 71.48% <ø> (+0.01%) ⬆️ Carriedforward from be27fb1

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

Files with missing lines Coverage Δ
...nd/src/descriptors/CustomOpOperationDescriptor.hpp 100.00% <ø> (ø)
...cts/hipdnn/backend/src/descriptors/NodeFactory.cpp 100.00% <100.00%> (ø)
...hipdnn_frontend/detail/DescriptorUnpackHelpers.hpp 83.41% <100.00%> (+4.91%) ⬆️
...clude/hipdnn_frontend/detail/OperationUnpacker.hpp 100.00% <100.00%> (ø)
...nd/src/descriptors/CustomOpOperationDescriptor.cpp 99.47% <98.00%> (-0.53%) ⬇️
...tend/include/hipdnn_frontend/node/CustomOpNode.hpp 94.39% <83.33%> (-0.66%) ⬇️
.../include/hipdnn_frontend/detail/CustomOpPacker.hpp 75.00% <81.82%> (+2.78%) ⬆️
...nclude/hipdnn_frontend/detail/CustomOpUnpacker.hpp 75.00% <75.00%> (ø)

... and 55 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.

SamuelReeder and others added 5 commits March 26, 2026 21:40
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the _inputDescs.empty() check from
CustomOpOperationDescriptor::finalize() so that custom operations with
zero inputs (output-only generators) are valid.

Add backend tests for zero-input fromNode round-trip and zero-input
graph descriptor serialization, plus an integration test verifying the
full lower-lift cycle with zero inputs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…llowed

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@SamuelReeder SamuelReeder marked this pull request as ready for review March 26, 2026 22:13
@SamuelReeder SamuelReeder requested a review from a team as a code owner March 26, 2026 22:13
Comment thread projects/hipdnn/frontend/tests/TestDescriptorUnpackHelpers.cpp
SamuelReeder and others added 2 commits March 26, 2026 22:21
Extract the repeated 7-call expectFullTensorMocksForDesc mock sequence into a
single free function in an anonymous namespace. Both TestUnpackTensorAttributes
and TestUnpackAndRegisterTensorArray now delegate to this shared helper, and the
large inline duplicate in UnpackAndRegisterTensorNewTensor is gone.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…operation name

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Comment thread projects/hipdnn/backend/tests/descriptors/TestGraphDescriptorCustomOp.cpp Outdated
Comment thread projects/hipdnn/backend/tests/descriptors/TestGraphDescriptorCustomOp.cpp Outdated
Comment thread projects/hipdnn/backend/tests/descriptors/TestCustomOpOperationFromNode.cpp Outdated
Copy link
Copy Markdown
Contributor

@BrianHarrisonAMD BrianHarrisonAMD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

We should fix the couple issues noted before merge.

SamuelReeder and others added 2 commits March 27, 2026 15:55
…-port tests, use toVec helper

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…iopen-1625/add-custom-op-lifting

# Conflicts:
#	projects/hipdnn/backend/src/descriptors/NodeFactory.hpp
SamuelReeder and others added 4 commits March 27, 2026 16:51
…d static-in-anon-namespace warning

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…iopen-1625/add-custom-op-lifting

# Conflicts:
#	projects/hipdnn/frontend/include/hipdnn_frontend/detail/DescriptorUnpackHelpers.hpp
…by-value tests

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…skip behavior

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@SamuelReeder SamuelReeder merged commit 187809b into develop Mar 30, 2026
32 of 36 checks passed
@SamuelReeder SamuelReeder deleted the users/sareeder/almiopen-1625/add-custom-op-lifting branch March 30, 2026 04:41
vidyasagar-amd pushed a commit that referenced this pull request Apr 9, 2026
## Motivation

Adds descriptor-based lifting support for the CustomOp operation,
enabling reconstruction of frontend graph attributes from serialized
FlatBuffer data. This completes the round-trip path: frontend graph →
descriptor lowering → serialize → deserialize → descriptor lifting →
frontend graph.

## Technical Details

Added `fromNode()` static factory method to
`CustomOpOperationDescriptor` that reconstructs descriptor state from
FlatBuffer `NodeT` data, resolving tensor UIDs from the shared tensor
map. Added `HIPDNN_ATTR_OPERATION_NAME_EXT` and
`HIPDNN_ATTR_OPERATION_TYPE_EXT` attribute support to
`setAttribute()`/`getAttribute()`. Created `CustomOpUnpacker.hpp` that
unpacks tensor arrays, byte arrays (opaque buffer), compute data type,
and operation name from the C-API descriptor.

**Note:** updated the CustomOpOperationDescriptor to allow finalization
with 0 inputs or outputs on the descriptor. This matches the frontend,
but there was inconsistency in the backend.

## Test Plan

- [x] 13 fromNode round-trip unit tests (lifecycle, tensor references,
data fields, name preservation, missing tensor failures)
- [x] 3 name preservation tests in `TestGraphDescriptorCustomOp`
- [x] 4 integration lifting tests including
`AutoAssignedUidsPreservedInRoundTrip`
- [x] `TestOperationUnpacker` case for CustomOp
- [x] Shared test constants used throughout

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

3 participants