Skip to content

[Torchvision API] Exception for isolated objective operator execution#6373

Open
mdabek-nvidia wants to merge 2 commits into
NVIDIA:mainfrom
mdabek-nvidia:torchvision_error_msg_for_isolated_operators
Open

[Torchvision API] Exception for isolated objective operator execution#6373
mdabek-nvidia wants to merge 2 commits into
NVIDIA:mainfrom
mdabek-nvidia:torchvision_error_msg_for_isolated_operators

Conversation

@mdabek-nvidia
Copy link
Copy Markdown
Collaborator

Category:

Bug fix

Description:

RuntimeError raised when executing a standalone operator, which is not a part of a Compose pipeline.

Additional information:

Affected modules and functionalities:

Key points relevant for the review:

Tests:

  • Existing tests apply
  • 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: DALI-4644

@mdabek-nvidia mdabek-nvidia marked this pull request as ready for review May 27, 2026 08:25
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 27, 2026

Greptile Summary

This bug fix improves the error experience when a DALI torchvision Operator is invoked standalone, outside of a Compose pipeline. Previously the operator's __call__ would run internal pipeline logic against a raw tensor and produce a cryptic internal RuntimeError; now it immediately raises a clear, descriptive RuntimeError pointing the user to Compose.

  • operator.py: __call__ now raises a descriptive RuntimeError; the original execution logic is moved verbatim into a new private _invoke method.
  • compose.py: _pipeline_function updated from op(input_node) to op._invoke(input_node), the sole call-site inside the pipeline graph builder.
  • test_tv_compose.py: adds test_error_in_isolated_operators that asserts the new error fires with the expected message glob.

Confidence Score: 5/5

Safe to merge — the change is a straightforward split of __call__ into a hard-failing stub and a private _invoke, with a matching one-line update in compose.py and a covering test.

The three changed files are tightly coupled and the logic move is mechanical: no execution logic was altered, only the call-site routing changed. The new test verifies the error path with a message glob. No regressions to existing behavior are expected.

No files require special attention.

Important Files Changed

Filename Overview
dali/python/nvidia/dali/experimental/torchvision/v2/operator.py Splits __call__ into a hard-failing stub (raises RuntimeError) and a new private _invoke method that carries the original execution logic; the change is clean and well-scoped.
dali/python/nvidia/dali/experimental/torchvision/v2/compose.py One-line update to call op._invoke(input_node) instead of op(input_node); straightforward and necessary follow-up to the operator.py change.
dali/test/python/torchvision/test_tv_compose.py Adds test_error_in_isolated_operators that verifies the new RuntimeError is raised with the expected message glob; uses assert_raises with a message pattern per DALI convention.

Sequence Diagram

sequenceDiagram
    participant User
    participant Operator
    participant Compose
    participant _pipeline_function

    Note over User,Operator: Direct call (now blocked)
    User->>Operator: op(data_input)
    Operator-->>User: RuntimeError: not directly callable

    Note over User,_pipeline_function: Correct path via Compose
    User->>Compose: compose(data_input)
    Compose->>_pipeline_function: build pipeline graph
    _pipeline_function->>Operator: op._invoke(input_node)
    Operator-->>_pipeline_function: pipeline DataNode
    _pipeline_function-->>Compose: output node
    Compose-->>User: torch.Tensor / PIL.Image
Loading

Reviews (4): Last reviewed commit: "Adjust Compose tests" | Re-trigger Greptile

Comment thread dali/python/nvidia/dali/experimental/torchvision/v2/operator.py
Comment thread dali/python/nvidia/dali/experimental/torchvision/v2/operator.py Outdated
Comment thread dali/python/nvidia/dali/experimental/torchvision/v2/compose.py Outdated
@mdabek-nvidia mdabek-nvidia force-pushed the torchvision_error_msg_for_isolated_operators branch from c8582af to 4f54085 Compare May 27, 2026 08:40
Signed-off-by: Marek Dabek <mdabek@nvidia.com>
@mdabek-nvidia mdabek-nvidia force-pushed the torchvision_error_msg_for_isolated_operators branch from 4f54085 to d84095e Compare May 27, 2026 08:49
Signed-off-by: Marek Dabek <mdabek@nvidia.com>
@mdabek-nvidia
Copy link
Copy Markdown
Collaborator Author

@greptileai re-review

@mdabek-nvidia mdabek-nvidia changed the title Exception for isolated objective operator execution [Torchvision API] Exception for isolated objective operator execution May 27, 2026
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.

4 participants