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

Move decoders to decoders module #2725

Merged
merged 5 commits into from Mar 1, 2021
Merged

Conversation

klecki
Copy link
Contributor

@klecki klecki commented Feb 25, 2021

Add alias test for image decoder - split decoder is broken.
Signed-off-by: Krzysztof Lecki klecki@nvidia.com

Why we need this PR?

Refactoring to introduce decoders module.

What happened in this PR?

  • What solution was applied:
    Introduce alias operators for audio and image* decoders. Move the main ones to decoders module
  • Affected modules and functionalities:
    Decoders operators
  • Key points relevant for the review:
    Look out for typos?
  • Validation and testing:
    Sanity alias tests
  • Documentation (including examples):
    Yes.

JIRA TASK: [DALI-1882]

@@ -185,8 +185,8 @@ image format, it will decode the entire image and crop the selected ROI.

.. note::
ROI decoding is currently not compatible with hardware-based decoding. Using
:meth:`nvidia.dali.fn.image_decoder` automatically disables hardware accelerated
decoding. To use the hardware decoder, use the :meth:`nvidia.dali.fn.image_decoder` and
:meth:`nvidia.dali.fn.decoders.image` automatically disables hardware accelerated
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a typo (the doc before). It should be image_decoder_crop/decoders.image_crop

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

:meth:`nvidia.dali.fn.image_decoder` automatically disables hardware accelerated
decoding. To use the hardware decoder, use the :meth:`nvidia.dali.fn.image_decoder` and
:meth:`nvidia.dali.fn.decoders.image` automatically disables hardware accelerated
decoding. To use the hardware decoder, use the :meth:`nvidia.dali.fn.decoders.image` and
Copy link
Contributor

Choose a reason for hiding this comment

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

That one is correct

// Deprecated aliases

DALI_SCHEMA(ImageDecoder)
.DocStr("Legacy alias for :meth:`decoders.image_decoder`.")
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
.DocStr("Legacy alias for :meth:`decoders.image_decoder`.")
.DocStr("Legacy alias for :meth:`decoders.image`.")

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 for all

// Fused

DALI_SCHEMA(ImageDecoderCrop)
.DocStr("Legacy alias for :meth:`decoders.image_decoder_crop`.")
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
.DocStr("Legacy alias for :meth:`decoders.image_decoder_crop`.")
.DocStr("Legacy alias for :meth:`decoders.image_crop`.")

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

functionality to allow for backward compatibility.)code"); // Deprecated in 1.0

DALI_SCHEMA(ImageDecoderRandomCrop)
.DocStr("Legacy alias for :meth:`decoders.image_decoder_random`.")
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
.DocStr("Legacy alias for :meth:`decoders.image_decoder_random`.")
.DocStr("Legacy alias for :meth:`decoders.image_random_crop`.")

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



DALI_SCHEMA(ImageDecoderSlice)
.DocStr("Legacy alias for :meth:`decoders.image_decoder_slice`.")
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
.DocStr("Legacy alias for :meth:`decoders.image_decoder_slice`.")
.DocStr("Legacy alias for :meth:`decoders.image_slice`.")

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

batch_size_alias_test=16

@pipeline_def(batch_size=batch_size_alias_test, device_id=0, num_threads=4)
def decoder_pipe(decoder_op, file_root, device, use_fast_idct, split_stages):
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 For testing split_stages

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If only it would work.

Copy link
Contributor

Choose a reason for hiding this comment

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

:)

Add alias test for image decoder - split decoder is broken.
TODO: test for audio decoder

Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
@klecki klecki marked this pull request as ready for review March 1, 2021 13:06
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
@klecki
Copy link
Contributor Author

klecki commented Mar 1, 2021

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2119200]: BUILD STARTED

Copy link
Member

@szalpal szalpal left a comment

Choose a reason for hiding this comment

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

Some indentation issues, please fix them.

Also a comment from my side, if we deprecate some operators, shouldn't we keep them out of the table?
image
Or (at least) notify the user better, that he really shouldn't use them... But that's not a blocker, probably out of scope of this PR

Comment on lines 129 to 132
def check_audio_decoder_alias(sample_rate, downmix, quality, dtype):
new_pipe = decoder_pipe(fn.decoders.audio, sample_rate, downmix, quality, dtype)
legacy_pipe = decoder_pipe(fn.audio_decoder, sample_rate, downmix, quality, dtype)
compare_pipelines(new_pipe, legacy_pipe, batch_size_alias_test, 10)
Copy link
Member

Choose a reason for hiding this comment

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

Peculiar indent

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

yield check_image_decoder_alias, new_op, old_op, data_path, device, use_fast_idct, split_stages

def test_image_decoder_split_alias():
raise SkipTest("Sanity tests for aliases of split decoder are temporarily disabled due to accuracy issues.")
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't nose give an option in decorator to intentionally skip a test? For sure there's a @nottest, I don't know how about skipping with explanation...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the way. @nottest have totally different meaning than skipping a test.

new_op, old_op = fn.decoders.image_slice, fn.image_decoder_slice
for device in ["cpu", "mixed"]:
for use_fast_idct in [True, False]:
yield check_image_decoder_slice_alias, new_op, old_op, data_path, device, use_fast_idct
Copy link
Member

Choose a reason for hiding this comment

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

Peculiar indent

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

Comment on lines 170 to 172
new_pipe = decoder_slice_pipe(new_op, file_root, device, use_fast_idct)
legacy_pipe = decoder_slice_pipe(old_op, file_root, device, use_fast_idct)
compare_pipelines(new_pipe, legacy_pipe, batch_size_alias_test, 10)
Copy link
Member

Choose a reason for hiding this comment

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

Peculiar indent

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

for device in ["cpu", "mixed"]:
for use_fast_idct in [True, False]:
for split_stages in [False]:
yield check_image_decoder_alias, new_op, old_op, data_path, device, use_fast_idct, split_stages
Copy link
Member

Choose a reason for hiding this comment

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

Peculiar indent

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

Comment on lines 135 to 137
new_pipe = decoder_pipe(new_op, file_root, device, use_fast_idct, split_stages)
legacy_pipe = decoder_pipe(old_op, file_root, device, use_fast_idct, split_stages)
compare_pipelines(new_pipe, legacy_pipe, batch_size_alias_test, 10)
Copy link
Member

Choose a reason for hiding this comment

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

Peculiar indent

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

@klecki
Copy link
Contributor Author

klecki commented Mar 1, 2021

@szalpal
As for the table - I'd say it's fine. It says that this is legacy alias and points you to the correct operator. There is also the whole explanation by each of the operators and you get a warning with the same message.

Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2119200]: BUILD PASSED

@klecki
Copy link
Contributor Author

klecki commented Mar 1, 2021

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2119446]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2119446]: BUILD PASSED

@klecki klecki merged commit 95eb208 into NVIDIA:master Mar 1, 2021
@JanuszL JanuszL mentioned this pull request May 19, 2021
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