Skip to content

Promote scalars to constants in ndd arithmetic operators - #6475

Open
rostan-t wants to merge 2 commits into
NVIDIA:mainfrom
rostan-t:ndd-optimize-arithm-ops
Open

Promote scalars to constants in ndd arithmetic operators#6475
rostan-t wants to merge 2 commits into
NVIDIA:mainfrom
rostan-t:ndd-optimize-arithm-ops

Conversation

@rostan-t

@rostan-t rostan-t commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Category:

Bug fix (non-breaking change which fixes an issue)

Description:

Currently, integers and floats are not promoted to constants in ndd arithmetic operators. This PR fixes it.

With a and b two 64x224x224x3 batches of uint8 images on the GPU, 0.4 * a + 0.6 * b takes around 640 us to run on main and below 230 us on this branch.

One important detail is that all bool/int/floats are currently promoted to constants, forcing the creation of a new operator instance each time. PR #6476 addresses this issue.

Additional information:

Affected modules and functionalities:

Airthmetic ops

Key points relevant for the review:

Tests:

  • Existing tests apply: test_arithm_ops.py
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: N/A

Signed-off-by: Rostan Tabet <rtabet@nvidia.com>
Signed-off-by: Rostan Tabet <rtabet@nvidia.com>
@rostan-t rostan-t added the dynamic mode Related to dynamic mode label Sep 9, 2026
@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge with no actionable correctness, security, compatibility, or repository-rule violations identified.

Summary

  • Separates tensor operands from built-in boolean, integer, and floating-point constants.
  • Preserves CPU/GPU placement checks for operands that still require tensor conversion.
  • Marks the internal arithmetic constant vectors as ordinary schema arguments rather than tensor-capable arguments.

@rostan-t rostan-t changed the title Optimize arithmetic operators in ndd Promote scalars to constants in ndd arithmetic operators Sep 9, 2026
@rostan-t

rostan-t commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

!build

@dali-automaton

Copy link
Copy Markdown
Collaborator

CI MESSAGE: [66962649]: BUILD STARTED

@mzient mzient self-assigned this Sep 9, 2026
@dali-automaton

Copy link
Copy Markdown
Collaborator

CI MESSAGE: [66962649]: BUILD PASSED

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

Labels

dynamic mode Related to dynamic mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants