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

Rounding Convert and ConvertSat added. #1068

Merged
merged 4 commits into from Jul 12, 2019
Merged

Conversation

mzient
Copy link
Contributor

@mzient mzient commented Jul 11, 2019

Signed-off-by: Michal Zientkiewicz michalz@nvidia.com

Why we need this PR?

  • It applies rounding when necessary, leaving the result un-rounded otherwise.

What happend in this PR?

  • Added rounding to Convert and ConvertSat
  • Added cuda_round_helper and use intrinsic functions for rounding conversion.
  • Added Converter class to avoid excessive number of enable_if variants of Convert[Norm][Sat].
  • Added trivial specialization for Converter

Usage:
Convert<OutputType, [InputType]>(value) - converts value from (possibly inferred) InputType to OutputType, rounding if necessary

ConvertNorm<OutputType, [InputType]>(value) - converts value from (possibly inferred) InputType to OutputType, rounding if necessary and normalizing range.
Range normalization rules:

  • int->float: divide integers by max value for input type
  • float->int: multiply by max value for output type
  • intX->intY: same as intX->float->intY

ConvertSat<OutputType, [InputType]>(value) - converts value and clamp it to the range of OutputType

ConvertSatNorm<OutputType, [InputType]>(value) - scale value from input to output type, with appropriate clamping.

With normalization, clamping is not necessary when converting:

  • integers to floating point types
  • integers to signed integers
  • unsigned integers to unsigned integers.
    These cases are recognized and handled efficiently.
    Clamping is still necessary when converting unsigned to signed integers and floating point values to integers.

@mzient
Copy link
Contributor Author

mzient commented Jul 11, 2019

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [810254]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [810254]: BUILD PASSED

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
* Add ./include to directory list processed by Doxygen.

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@mzient
Copy link
Contributor Author

mzient commented Jul 12, 2019

!build

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [811538]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [811541]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [811541]: BUILD PASSED

@mzient mzient merged commit 6bebd75 into NVIDIA:master Jul 12, 2019
haoxintong pushed a commit to haoxintong/DALI that referenced this pull request Jul 16, 2019
* Rounding Convert and ConvertSat added.
* Add a Converter helper class to avoid excessive number of `enable_if`s.
* Add documentation for `Convert[Sat][Norm]` function family.
* Add ./include to directory list processed by Doxygen.

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
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