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

BrightnessContrast operator #1188

Merged
merged 47 commits into from
Sep 25, 2019
Merged

BrightnessContrast operator #1188

merged 47 commits into from
Sep 25, 2019

Conversation

szalpal
Copy link
Member

@szalpal szalpal commented Aug 21, 2019

Why we need this PR?

Pick one

  • Add BrightnessContrast operator

What happened in this PR?

Added operator plus few utilities

JIRA TASK: [DALI-821]

Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
@szalpal
Copy link
Member Author

szalpal commented Sep 17, 2019

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [903753]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [903753]: BUILD FAILED

@szalpal
Copy link
Member Author

szalpal commented Sep 17, 2019

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [903760]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [903760]: BUILD FAILED

dali/pipeline/operators/color/brightness_contrast.h Outdated Show resolved Hide resolved
const auto &input = ws.template Input<Backend>(0);
auto &output = ws.template Output<Backend>(0);

TYPE_SWITCH(input.type().id(), type2id, InputType, (uint8_t, int16_t, int32_t, float), (
Copy link
Contributor

Choose a reason for hiding this comment

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

DALI_TYPE_SWITCH_WITH_FP16 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding types, that are supported here, I followed requirements, so I'd like to manually specify types, that are supported

Copy link
Contributor

Choose a reason for hiding this comment

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

It says:

Output types: [u8, i8, u16, i16, u32, i32, f32]
Input types: [u8, i8, u16, i16, u32, i32, f32]

you are not covering all the cases.

In my opinion, there is no reason for not using the DALI_TYPE_SWITCH_WITH_FP16 here and cover all available types

dali/pipeline/operators/color/brightness_contrast_test.cu Outdated Show resolved Hide resolved
dali/pipeline/workspace/workspace.h Show resolved Hide resolved
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>
@szalpal
Copy link
Member Author

szalpal commented Sep 18, 2019

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [905683]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [905683]: BUILD PASSED

Additionally, this operator can change the type of data.)code")
.NumInput(1)
.NumOutput(1)
.AddOptionalArg(detail::kBrightness,
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking about that problem. I'd rather make it belong to Operator class than to detail namespace. I would at least change that.

Still it's not aligned with the rest of the code base.

auto tvout = view<OutputType, 3>(output);
kernel_manager_.Initialize<BrightnessContrastKernel>();
kernels::KernelContext ctx;
kernel_manager_.Setup<BrightnessContrastKernel>(ws.data_idx(),
Copy link
Contributor

Choose a reason for hiding this comment

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

What's your opinion on calling kernel::Setup in Operator::SetupImpl`?

Copy link
Member Author

Choose a reason for hiding this comment

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

Generally speaking, I'd say that it should be this way. However, here we have a special case. Meaning, it's not necessary to call Setup in SetupImpl. On the other hand, implementing it this way would require major change with duplicating TYPE_SWITCHes, which obfuscates the code. While it would be possible to do this implementation without such duplication, the abstraction layer for this is not ready yet and will require some time to evolve. Keeping all this in mind, plus taking into account, that this PR is already quite a time here (I already rebased it twice), I'd like to merge it now and, when it proves to be necessary, add the abstraction layer later.

dali/pipeline/operators/util/external_source.h Outdated Show resolved Hide resolved

private:
USE_OPERATOR_MEMBERS();
detail::argument_t<Backend> brightness_, contrast_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe personal preference:
A little bit of an overkill in my opinion. I'd rather have vector<float> all the time and get rid of argument_t. It will just have 1 element for CPUBackend and more than that for GPUBackend

Co-Authored-By: Joaquin Anton <j.anton.guirao@gmail.com>
@szalpal
Copy link
Member Author

szalpal commented Sep 25, 2019

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [916886]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [916886]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [916886]: BUILD PASSED

@szalpal szalpal merged commit c2d44f7 into NVIDIA:master Sep 25, 2019
00liujj pushed a commit to 00liujj/DALI that referenced this pull request Oct 10, 2019
* BrightnessContrast operator

Signed-off-by: Michał Szołucha <mszolucha@nvidia.com>

Co-Authored-By: Joaquin Anton <j.anton.guirao@gmail.com>
Signed-off-by: Jianjun Liu <00liujj@163.com>
@szalpal szalpal deleted the bricon_op branch November 20, 2019 11:19
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

5 participants