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

Fix and reenable optimized Cast kernel #3976

Merged
merged 3 commits into from
Jun 13, 2022

Conversation

klecki
Copy link
Contributor

@klecki klecki commented Jun 8, 2022

Category: Bug fix

Description:

The bug in binsearch Cast kernel manifested
on empty samples - there was mismatch between
sample that was assigned to a given block
and the block that was assumed by the kernel
due to BlockDescriptos not being generated
for samples with 0 volume.

Now, the empty samples are skipped at the
end of the batch and when assigning the
lowest blockIdx to a given sample.

The binsearch looks for the rightmost
sample when searching the descriptors.

Test was adjusted to not generate empty samples
and another was added to randomly make
selected ranges of samples empty.

The speedup compared to the old implementation
is between 10% and 25%, averaging 16%, depending
on the size of the input.

Additionally the collapsed shape was reused
for the data volume.

Additional information:

Affected modules and functionalities:

Cast

Key points relevant for the review:

Can I assume that there is at least one non-empty sample?
Should I add a check?

Tests:

  • Existing tests apply
    • Recently extended Python Cast test was adjusted to not generate 0 samples randomly
      and another one was added to do that in controlled manner.
  • 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

The bug in binsearch Cast kernel manifested
on empty samples - there was mismatch between
sample that was assigned to a given block
and the block that was assumed by the kernel
due to BlockDescriptos not being generated
for samples with 0 volume.

Now, the empty samples are skipped at the
end of the batch and when assigning the
lowest blockIdx to a given sample.

The binsearch looks for the rightmost
sample when searching the descriptors.

Test was adjusted to not generate empty samples
and another was added to randomly make
selected ranges of samples empty.

The speedup compared to the old implementation
is between 10% and 25%, averaging 16%, depending
on the size of the input.

Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
@klecki
Copy link
Contributor Author

klecki commented Jun 8, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5045144]: BUILD STARTED

@klecki
Copy link
Contributor Author

klecki commented Jun 8, 2022

CC @MirazSpecial

start = 0
end = rng.integers(1, len(input) // 3)
elif empty_volume_policy == "right":
start = rng.integers(1, len(input) * 2 // 3)
Copy link
Contributor

@mzient mzient Jun 8, 2022

Choose a reason for hiding this comment

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

Suggested change
start = rng.integers(1, len(input) * 2 // 3)
start = rng.integers(len(input) * 2 // 3, len(input) - 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@mzient mzient self-assigned this Jun 8, 2022
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
@klecki
Copy link
Contributor Author

klecki commented Jun 8, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5045304]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5045304]: BUILD PASSED

@klecki klecki merged commit df90d36 into NVIDIA:main Jun 13, 2022
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.

None yet

4 participants