Skip to content

Fix equalize unit test#5456

Merged
stiepan merged 2 commits intoNVIDIA:mainfrom
stiepan:fix_lut_test
May 7, 2024
Merged

Fix equalize unit test#5456
stiepan merged 2 commits intoNVIDIA:mainfrom
stiepan:fix_lut_test

Conversation

@stiepan
Copy link
Member

@stiepan stiepan commented May 6, 2024

Category:

Other (e.g. Documentation, Tests, Configuration)

Description:

Fixes a bug in equalize unit tests. One of the cases assumed the allocated memory is zero-ed out, while it is not.

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: N/A

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

stiepan commented May 6, 2024

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [14782104]: BUILD STARTED

Comment on lines +168 to +169
in_view[sample_idx].data[channel_idx * range_size + i] =
(i == 71 + channel_idx) ? ((sample_idx << 11) + channel_idx) : 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

This code looks almost as if intentionally obfuscated.

Suggested change
in_view[sample_idx].data[channel_idx * range_size + i] =
(i == 71 + channel_idx) ? ((sample_idx << 11) + channel_idx) : 0;
int index_of_nonzero_value = 71 + channel_idx;
int nonzero_value = (sample_idx << 11) + channel_idx;
in_view[sample_idx].data[channel_idx * range_size + i] =
i == index_of_nonzero_value ? nonzero_value : 0;

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@stiepan
Copy link
Member Author

stiepan commented May 6, 2024

!build

123 * channel_idx + sample_idx;
ASSERT_EQ(batch_shape[sample_idx][1], range_size);
for (int i = 0; i < range_size; i++) {
int index_of_nonzero_value = 71 + channel_idx;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
int index_of_nonzero_value = 71 + channel_idx;
int index_of_nonzero_value = sample_idx * 71 + channel_idx;

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [14782491]: BUILD STARTED

in_view[sample_idx].data[channel_idx * range_size + sample_idx * 71 + channel_idx] =
123 * channel_idx + sample_idx;
ASSERT_EQ(batch_shape[sample_idx][1], range_size);
int nonzero_idx = 71 + channel_idx;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to keep it constant across samples?

Copy link
Member Author

Choose a reason for hiding this comment

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

After all, why not. I added it back.

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

stiepan commented May 6, 2024

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [14783150]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [14783150]: BUILD PASSED

@stiepan stiepan merged commit 3184cb0 into NVIDIA:main May 7, 2024
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