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

Support CPU samples in predefined automatic augmentations #4772

Merged
merged 2 commits into from
Apr 7, 2023

Conversation

stiepan
Copy link
Member

@stiepan stiepan commented Apr 6, 2023

Category:

New feature (non-breaking change which adds functionality)

Description:

Now, that all predefined augmentations support CPU inputs, we can make the AutoAugment, RandAugment and TrivialAugment support the CPU samples. It is mostly a docs and tests update.

One extra thing is a change to the @augmentation decorator's param_device arg. It controls the backend of the Constant node with the precomputed argument for the augmentation. Initially, it supported simply cpu or gpu. For the most part, if the parameter is used in the augmentation as a named argument to some operator, it must be cpu. However, in some cases it is used as a positional argument (or implicitly so, with arithmetic operators). Then, it makes sense to put it on gpu if samples are on gpu too. For this reason, the third option is added, the "auto" option which infers the cpu, gpu backend from the sample's DataNode.

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-3296

Comment on lines 46 to 52
sample : DataNode
A batch of samples to be processed. The samples should be images of `HWC` layout,
`uint8` type and reside on GPU.
shapes: DataNode, optional
`uint8` type.
shape: DataNode, optional
Copy link
Contributor

@mzient mzient Apr 6, 2023

Choose a reason for hiding this comment

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

Nitpick: I'd rather use data / shape or samples / shapes - calling a batch of samples sample seems to be going a step too far.

Copy link
Member Author

Choose a reason for hiding this comment

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

On the one hand, it might be a bit controversial, on the other, it just fits the "sample" oriented style of DALI pipelines (maybe apart from manual/external source feeding of the inputs). You write the pipeline as if in terms of samples, but it produces batches. I am also reluctant to chaning the parameter name, as we already released this module, it would be kind of a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

But you did change the other - I know it's optional, but isn't the first argument positional anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

The change is only in the docs - I've mistekenly used plural in the docs, the actual argument name is shape.

Copy link
Member Author

Choose a reason for hiding this comment

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

Btw. I apparently fixed that typo in #4753, after rebasing it dissapeared here.

(True, False)))))
@params(*tuple(
enumerate(
itertools.product(("cpu", "gpu"), (True, False), (True, False), (None, 0), (True, False)))))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it really have to be a product? How long does this test take?
I'm not saying to change it, but rather to raise awareness about the potential impact of overusing Cartesian products of arguments.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I try to keep them from exploding. For example the batch_size and the number of magnitdue bins are function of the params above not a factor in the product.
Here, the test is rather fast and simple. Its point is excaly to make sure that the pipeline builds and runs with all the combinations of the major parameters.

Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
@stiepan
Copy link
Member Author

stiepan commented Apr 6, 2023

Rebased onto: #4753

@stiepan
Copy link
Member Author

stiepan commented Apr 6, 2023

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [7838523]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [7838523]: BUILD FAILED

Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
@stiepan
Copy link
Member Author

stiepan commented Apr 7, 2023

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [7885825]: BUILD STARTED

@stiepan stiepan added the automatic augmentations Automatic augmentations (AutoAugment, RandAugment, TrivialAugment and more) support in DALI. label Apr 7, 2023
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [7885825]: BUILD PASSED

@stiepan stiepan merged commit bf349fd into NVIDIA:main Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automatic augmentations Automatic augmentations (AutoAugment, RandAugment, TrivialAugment and more) support in DALI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants