Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata accessor #5650

Merged
merged 2 commits into from
Oct 1, 2024
Merged

Metadata accessor #5650

merged 2 commits into from
Oct 1, 2024

Conversation

mzient
Copy link
Contributor

@mzient mzient commented Sep 27, 2024

Category:

New feature (non-breaking change which adds functionality)
Refactoring (Redesign of existing code that doesn't affect functionality)

Description:

This PR reimplements GetProperty to allow for:

  • reuse of the 1st sample when the property is uniform across samples
  • return the data on any backend
  • return the data from input on any (Metadata) backend

It also introduces DataNode.metadata function and a shortcut for source_info.

NOTE layout doesn't get a dedicated accessor, since we want to have a static (build-time) layout and dtype.

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
  • X] N/A

DALI team only

Requirements

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

REQ IDs: N/A

JIRA TASK: N/A

dali/test/python/operator_1/test_get_property.py Dismissed Show dismissed Hide dismissed
dali/test/python/test_pipeline.py Fixed Show fixed Hide fixed
Signed-off-by: Michal Zientkiewicz <[email protected]>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [18914711]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [18914711]: BUILD PASSED


template <typename Backend>
auto GetProperty<Backend>::GetPropertyReader(std::string_view key) -> PropertyReader {
if (key == "source_info") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This if-else is fine for a couple (2-3) of properties. If we expect to have more of these I would recommend using different approach - e.g. unordered_map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Realistically, I'd expect maybe 5 qualitatively different properties. If we have anything more, it'll likely be standardized somehow and likely not even hardcoded.
Having said that - this function is called only on operator's construction - so it's not on a critical path.

@mzient mzient merged commit 0a98076 into NVIDIA:main Oct 1, 2024
6 checks passed
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