Skip to content

Add regex-based enum extraction to fix header parsing#1

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1764899759-regex-enum-extraction
Open

Add regex-based enum extraction to fix header parsing#1
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1764899759-regex-enum-extraction

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Dec 5, 2025

Copy link
Copy Markdown

Description

closes NVI-3

This PR replaces the hardcoded enum handling in cuda_bindings/setup.py with dynamic regex pattern matching to find CUDA enum types that pyclibrary.CParser fails to extract.

Changes

  • Added extract_enums_from_headers() function with three regex patterns to match:
    • typedef __device_builtin__ enum X Y; (CUDA-specific enum typedefs)
    • typedef enum X Y; (standard enum typedefs)
    • enum X {...} Y?; (inline enum declarations)
  • Integrated regex extraction into parse_headers() after CParser processing
  • Removed the manual CUstreamAtomicReductionDataType_enum addition and associated TODO comment
  • Preserved existing hardcoded replacements in the replace dictionary for backward compatibility

Human Review Checklist

  • Verify the regex patterns correctly match CUDA enum declarations in actual headers
  • Confirm CUstreamAtomicReductionDataType_enum is now found by the regex extraction (previously required manual addition)
  • Consider whether duplicate entries in found_types (from both CParser and regex) could cause downstream issues
  • The third regex pattern uses [^}]* which won't handle nested braces - verify this is acceptable for CUDA enum definitions

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Link to Devin run
Requested by: Shawn Azman (shawn@cognition.ai) (@ShawnAzman)

Implement extract_enums_from_headers() function that uses regex patterns
to dynamically find CUDA enum types that pyclibrary.CParser misses.

Changes:
- Add extract_enums_from_headers() function with three regex patterns:
  - typedef __device_builtin__ enum X Y; (CUDA-specific)
  - typedef enum X Y; (standard enum typedefs)
  - enum X {...} Y?; (inline enum declarations)
- Integrate regex extraction into parse_headers() after CParser processing
- Remove manual CUstreamAtomicReductionDataType_enum addition
- Preserve existing hardcoded replacements for backward compatibility

Fixes NVI-3

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant