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

Fix layout propagation in Erase #2133

Merged
merged 2 commits into from
Jul 20, 2020
Merged

Fix layout propagation in Erase #2133

merged 2 commits into from
Jul 20, 2020

Conversation

klecki
Copy link
Contributor

@klecki klecki commented Jul 20, 2020

Signed-off-by: Krzysztof Lecki klecki@nvidia.com

Why we need this PR?

Fix layout propagation in Erase

What happened in this PR?

  • What solution was applied:
    SetLayout(GetLayout())
    Fixes both Erase CPU and GPU.
    Adjust compare_pipelines and check_batch to allow layout checking,
    the former can accept tuple of layouts or single value,
    the check is optional.
    Adjust Erase Python tests.

  • Affected modules and functionalities:
    Erase, Python test utils.

  • Key points relevant for the review:
    NA

  • Validation and testing:
    Test adjusted

  • Documentation (including examples):
    NA

JIRA TASK: [DALI-1515]

Fixes both Erase CPU and GPU.
Adjust compare_pipelines and check_batch to allow layout checking,
the former can accept tuple of layouts or single value,
the check is optional.
Adjust Erase Python tests.

Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
@klecki
Copy link
Contributor Author

klecki commented Jul 20, 2020

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1481021]: BUILD STARTED

assert batch.layout() == expected_layout, \
'Unexpected layout, expected "{}", got "{}".'.format(expected_layout, batch.layout())

if compare_layouts and \
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't the first block of code enough? Why are you checking it again?

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's to compare between two batches (as opposed to providing the layout as argument to this function and checking if (where it can be check) we have a match with expected layout.

auto output = view<T, Dims>(ws.template OutputRef<GPUBackend>(0));
const auto &input_ref = ws.template InputRef<GPUBackend>(0);
auto &output_ref = ws.template OutputRef<GPUBackend>(0);
output_ref.SetLayout(input_ref.GetLayout());
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather use Operator's InputLayout function - I know that we don't have a default layout here, but it's proliferating the pattern which is not correct for the case with default input layout present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, the implementations are using the Operator class directly, but use the OperatorImpl as base and don't have access to this function. I will add this to the follow-up task, maybe we can do something better with it.

@@ -138,7 +181,12 @@ def compare_pipelines(pipe1, pipe2, batch_size, N_iterations, eps = 1e-07):
for i in range(len(out1)):
out1_data = out1[i].as_cpu() if isinstance(out1[i][0], dali.backend_impl.TensorGPU) else out1[i]
out2_data = out2[i].as_cpu() if isinstance(out2[i][0], dali.backend_impl.TensorGPU) else out2[i]
check_batch(out1_data, out2_data, batch_size, eps)
if isinstance(expected_layout, tuple):
Copy link
Contributor

Choose a reason for hiding this comment

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

list also?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it would be nice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Iterable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would say it's a test util, you need a iterable, you can extend it to your liking, but I don't see why we need to support 3 different possibilities here (as none is currently used).

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1481021]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1481021]: BUILD PASSED

@klecki klecki merged commit 2169c53 into NVIDIA:master Jul 20, 2020
@klecki klecki deleted the erase-fix branch July 20, 2020 15:40
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