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

Debug mode direct ExternalSource #3605

Merged

Conversation

ksztenderski
Copy link
Contributor

@ksztenderski ksztenderski commented Jan 3, 2022

Description

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (Redesign of existing code that doesn't affect functionality)
  • Other (e.g. Documentation, Tests, Configuration)

What happened in this PR

Adds debug version of ExternalSource operator removing additional callback to the backend. Before that, in the debug mode for external source we created a separate pipeline like for any other operator, which seems like an overkill considering that all of the ExternalSource implementation (relevant for debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Additional information

  • Affected modules and functionalities:
  • Key points relevant for the review:

Checklist

Tests

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

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

Add debug mode version of ExternalSource operator removing creation of seperate
pipeline for it.

Add TensorList constructor from list of Tensors.

Add seperation of preperation of data for feed_input from actual feed_input.

Add tests of ExternalSource in debug mode.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
@ksztenderski
Copy link
Contributor Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3690021]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3690021]: BUILD FAILED

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
@ksztenderski
Copy link
Contributor Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3693373]: BUILD STARTED

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

CI MESSAGE: [3693373]: BUILD PASSED

Copy link
Contributor

@klecki klecki left a comment

Choose a reason for hiding this comment

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

Comments only to TensorList constructor, I didn't read the rest yet.

auto &t = list_of_tensors[i].cast<Tensor<Backend>&>();
tv[i] = std::move(t);
}
tl->Copy(tv, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we probably should have a sync. We might do a Copy on some other stream (we have this stream pool that creates stream per-device), and sync on that stream, as syncing stream 0 might be a bit over the top.

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/python/backend_impl.cc Show resolved Hide resolved
@@ -142,3 +142,18 @@ def check_squeeze(shape, dim, in_layout, expected_out_layout):
(0, (1, 5, 1), "ABC", "BC"),
(None, (3, 5, 1), "ABC", "AB")]:
yield check_squeeze, shape, dim, in_layout, expected_out_layout


def test_tensorlist_constructor_from_list_of_tensors():
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be nice to test non-uniformly shaped TensorList as well (where each tensor has different dimensions).

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

ksztenderski and others added 3 commits January 11, 2022 10:12
Add test for TL with different tensors of different shapes

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
…derski/DALI into debug_mode_direct_external_source

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
@ksztenderski
Copy link
Contributor Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3735215]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3735215]: BUILD PASSED

@@ -55,6 +57,55 @@ def _get_default_stream_for_array(array):
else:
return None


def _prep_data_for_feed_input(data, batch_size, layout):
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a nitpick, we can probably move it to external_source.py

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

TensorVector<Backend> tv(list_of_tensors.size());
for (size_t i = 0; i < list_of_tensors.size(); ++i) {
auto &t = list_of_tensors[i].cast<Tensor<Backend>&>();
tv[i] = std::move(t);
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this move the data out of the list? Won't this be destructive function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to ShareData

dali/python/backend_impl.cc Show resolved Hide resolved
if self._num_outputs is not None:
for idx in range(self._num_outputs):
if self._batch:
raw_data = callback_out[idx]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this correct? We just save last output as raw_data here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was a mistake, fixed it.

if self._batch:
raw_data = callback_out[idx]
else:
raw_data = [callback_out[i][idx] for i in range(self._batch_size)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

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/python/nvidia/dali/_debug_mode.py Outdated Show resolved Hide resolved
Use ShareData in TL constructor from list of tensors instead of move

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
@ksztenderski
Copy link
Contributor Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3750054]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3750054]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3750054]: BUILD PASSED

@ksztenderski ksztenderski merged commit 2d40b1a into NVIDIA:main Jan 13, 2022
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Feb 21, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request May 13, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jun 7, 2022
Add direct external_source in debug mode

Adds debug version of ExternalSource operator removing additional callback
to the backend. Before that, in the debug mode for external source we created
a separate pipeline like for any other operator, which seems like an overkill
considering that all of the ExternalSource implementation (relevant for
the debug mode) is in Python.

Adds TensorList constructor from list of Tensors.

Signed-off-by: ksztenderski <ksztenderski@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.

4 participants