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

Add GPU filter operator (2D, 3D) #4525

Merged
merged 12 commits into from
Jan 4, 2023
Merged

Add GPU filter operator (2D, 3D) #4525

merged 12 commits into from
Jan 4, 2023

Conversation

stiepan
Copy link
Member

@stiepan stiepan commented Dec 19, 2022

Signed-off-by: Kamil Tokarski [email protected]

Category:

New feature (non-breaking change which adds functionality)

Description:

Adds GPU filter operator (2D and 3D convolutions with use-provided filters).

The relevant kernel part was merged here: #4298

Additional information:

  1. A basic usage is just providing a batch of samples and batch of filters as two positional arguments (filters can reside on CPU or GPU).
  2. By default the output has the same shape as the input, this means there is a need to handle somehow positions near the boundry that would cause OOB accesses. How it is done exactly is controlled with two parameters
  • border - what values to use to "pad" the input, possible modes are reflect 101, reflect 1001, wrap, clamp and constant. If the constant mode is used, user can provide a third argument that contains scalars to be used as a padding.
  • anchor - enables user to shift filter placement over the image
  1. Alternatively, the output can be smaller so that there are no OOB accesses - this can be controlled with mode parameter which can be "same" (default) or "valid".

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: DALI-2951

@stiepan stiepan marked this pull request as ready for review January 2, 2023 10:31
@stiepan
Copy link
Member Author

stiepan commented Jan 2, 2023

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [6915075]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [6915075]: BUILD FAILED

@stiepan
Copy link
Member Author

stiepan commented Jan 2, 2023

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [6915466]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [6915466]: BUILD PASSED

@jantonguirao jantonguirao self-assigned this Jan 3, 2023
the filter and the image.

)code")
.NumInput(2, 3)
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
.NumInput(2, 3)
.NumInput(2, 3)
.InputDox(0, "data", "TensorList", R"code(Batch of input data.)code")
.InputDox(1, "filter", "TensorList", R"code(Batch of filters.)code")
.InputDox(2, ...)

Please add documentation of the inputs, and perhaps remove the sentence in line 25.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, I moved whole sections from the main description to relevant parameters' docs.


.. note::
In fact, the operator computes a correlation, not a convolution,
i.e. the order of filter elements is not flipped when computing product of
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
i.e. the order of filter elements is not flipped when computing product of
i.e. the order of filter elements is not flipped when computing the product of

Copy link
Member Author

Choose a reason for hiding this comment

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

dine

.NumOutput(1)
.AllowSequences()
.AddOptionalArg("anchor",
R"code(Specifies position of the filter over the input.
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
R"code(Specifies position of the filter over the input.
R"code(Specifies the position of the filter over the input.

Copy link
Member Author

Choose a reason for hiding this comment

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

done


namespace filter {

extern template std::unique_ptr<OpImplBase<GPUBackend>>
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: use a macro to reduce verbosity?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

fill_value_bacthes = [list(fvs) for _, _, fvs in batches]

@pipeline_def
def piepline():
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
def piepline():
def pipeline():

Copy link
Member Author

Choose a reason for hiding this comment

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

done

const filter::InputDesc& input_desc);

bool SetupImpl(std::vector<OutputDesc>& output_desc, const Workspace& ws) override {
if (!impl_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

how about checking that the current impl_ instance matches the previous input and filter type?

Copy link
Member Author

Choose a reason for hiding this comment

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

It makes sense on the one hand, on the other isn't it something that should the exectur do?

@stiepan
Copy link
Member Author

stiepan commented Jan 3, 2023

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [6922910]: BUILD FAILED

@stiepan
Copy link
Member Author

stiepan commented Jan 3, 2023

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [6923202]: BUILD FAILED

stiepan added 12 commits January 3, 2023 19:14
Signed-off-by: Kamil Tokarski <[email protected]>
Signed-off-by: Kamil Tokarski <[email protected]>
Signed-off-by: Kamil Tokarski <[email protected]>
Signed-off-by: Kamil Tokarski <[email protected]>
Signed-off-by: Kamil Tokarski <[email protected]>
Signed-off-by: Kamil Tokarski <[email protected]>
Signed-off-by: Kamil Tokarski <[email protected]>
Add variable batch size test
Add volumetric tests

Signed-off-by: Kamil Tokarski <[email protected]>
Signed-off-by: Kamil Tokarski <[email protected]>
Signed-off-by: Kamil Tokarski <[email protected]>
@stiepan
Copy link
Member Author

stiepan commented Jan 3, 2023

I had to rebase over the operator tests split.

@stiepan
Copy link
Member Author

stiepan commented Jan 3, 2023

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [6923309]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [6923309]: BUILD PASSED

.AddOptionalArg("border",
R"code(Controls how to handle out-of-bound filter positions over the sample.

Supported values are: ``"reflect_101"``, ``"reflect_1001"``, ``"wrap"``,
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the tests I've seen just "101" and "1001" values and not "reflect_*". Is it something different?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's the same, just out of convenience.

The boundary.h

if (type == "reflect_1001" || type == "reflect1001" || type == "1001")

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, understood

@stiepan stiepan merged commit 8db68c1 into NVIDIA:main Jan 4, 2023
aderylo pushed a commit to zpp-dali-2022/DALI that referenced this pull request Mar 17, 2023
* Add GPU filter operator (2D, 3D)

Signed-off-by: Kamil Tokarski <[email protected]>
@JanuszL JanuszL mentioned this pull request Sep 6, 2023
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.

5 participants