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

CPU argument input #1423

Merged
merged 8 commits into from
Oct 27, 2019
Merged

CPU argument input #1423

merged 8 commits into from
Oct 27, 2019

Conversation

mzient
Copy link
Contributor

@mzient mzient commented Oct 25, 2019

Why we need this PR?

  • Refactoring to improve remove the support operators from DALI.
    To make DALI simple and more flexible the current Support operators can be reworked to regular CPU operators. To make this working, the argument inputs had to be reworked to accept CPU operator outputs.

What happened in this PR?

  1. Graph verification had to be modified to allow CPU operators to be plugged into the input arguments.
  2. Argument input is now a TensorVector not a TensorList. This change was made to be consistent with the type of CPU operators outputs.
  3. Existing operators that use argument input had to be reworked to conform to the new api.
  4. Existing support operators (CoinFlip, Uniform) were changed to CPU operators.
  5. Some mechanical changes in the tests had to be done.
  6. Total removal of SupportBackend, SupportWorkspace, etc
  7. When using separated queue policy, a MakeContiguous node is inserted before passing ArgumentInputs to GPU ops.
  8. TensorVector can now be created as a "view" at a TensorList, with ability to be updated afterwards to track changes to the underlying TensorList.

There will be a follow-up PR that removes any notion of support operators from DALI code and docs.

JIRA TASK: [DALI-687]

@mzient
Copy link
Contributor Author

mzient commented Oct 25, 2019

!build

banasraf and others added 4 commits October 25, 2019 11:56
* Change type of existing support operators
* Remove support device from tests
* Review fixes

Author: Rafal Banas <Banas.Rafal97@gmail.com>
Signed-off-by: Rafal Banas <Banas.Rafal97@gmail.com>
… ArgumentInputs of GPU operators.

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
- Update TensorVectors in ArgumentWorkspace when created from TensorLists.
- Make TensorVector `UpdateViews` a public function.

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

CI MESSAGE: [961040]: BUILD FAILED

* Rename AcquireTensorArgument to GetPerSampleArgument
* Make GetPerSampleArgument work with TensorVector

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

CI MESSAGE: [961155]: BUILD STARTED

@mzient mzient changed the title Cpu argument input CPU argument input Oct 25, 2019
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@@ -368,11 +368,11 @@ TYPED_TEST(TensorTest, TestShareData) {
}

TYPED_TEST(TensorTest, TestCopyToTensorList) {
std::vector<Tensor<TypeParam>> tensors(16);
TensorVector<CPUBackend> tensors(16);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change from parametrized backend to only CPUBackend here?
Also, as you changed the std::vector to TensorVector it would be good to test both modes of TensorVector, the contiguous (backed by TL) and noncontiguous (separate Tensors).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverting to TypeParam.
Testing contiguous copy seems a bit excessive when there's no special code path for such case. When we added, it's going to be useful, though.

…ces to "support" device.

Restore backend parameter in TestCopyToTensorList.

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

CI MESSAGE: [961194]: BUILD STARTED

@mzient mzient requested a review from klecki October 25, 2019 12:56
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@JanuszL JanuszL requested a review from ptrendx October 25, 2019 13:21
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [961232]: BUILD STARTED

bool is_valid_shape = shape.tensor_shape(0) == TensorShape<1>{batch_size_};

DALI_ENFORCE(is_valid_shape,
make_string("`", argument_name, "` must be a 1xN or Nx1 (N = ", batch_size_,
Copy link
Contributor

@klecki klecki Oct 25, 2019

Choose a reason for hiding this comment

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

Nitpick, the make_string adds spaces automatically, so you will get (N_=__10) etc

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 that's the only thing, then I'll do it in another PR.

auto tensor = queue[idxs[OpType::SUPPORT]];
ws.AddArgumentInput(tensor, arg_pair.first);
auto &parent_node = graph.Node(graph.Tensor(tid).producer.node);
auto parent_op_type = parent_node.op_type;
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
auto parent_op_type = parent_node.op_type;
auto parent_op_idx = idxs[parent_node.op_type];

"Argument Inputs must be stored in CPU memory");

auto add_arg_input = [&](auto &queue) {
auto tensor = queue[idxs[parent_op_type]];
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
auto tensor = queue[idxs[parent_op_type]];
auto tensor = queue[parent_op_idx];

}

protected:
struct ArgumentInputDesc {
shared_ptr<TensorVector<CPUBackend>> tvec;
bool should_update = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment describing what and why should be updated?

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [961232]: BUILD PASSED

@mzient mzient merged commit 835405b into NVIDIA:master Oct 27, 2019
rbetz pushed a commit to rbetz/DALI that referenced this pull request Oct 28, 2019
* Make input arguments accept TensorVector
* Change type of existing support operators
* Remove support device from tests
* Remove SupportWorkspace and SupportBackend. Insert MakeContiguous for ArgumentInputs of GPU operators.
* Make TensorVector track changes in underlying TensorList.
* Update TensorVectors in ArgumentWorkspace when created from TensorLists.
* Make TensorVector `UpdateViews` a public function.
* Deprecate \"support\" device.

Co-authored-by: Rafal Banas <Banas.Rafal97@gmail.com>
Signed-off-by: Rafal Banas <Banas.Rafal97@gmail.com>
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

6 participants