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 sequence and 3D support in flip operator #1439

Merged
merged 6 commits into from
Nov 13, 2019

Conversation

banasraf
Copy link
Collaborator

@banasraf banasraf commented Nov 4, 2019

Signed-off-by: Rafal Banas.Rafal97@gmail.com

Why we need this PR?

It extends the flip operator to support volumetric inputs and sequences.

What happened in this PR?

  • Flip kernels were ready to support volumetric data. I've extended them to support sequences.
  • Was this PR tested? How?
    The kernel tests were extended and python tests for sequences and volumetric inputs were added
  • Were docs and examples updated, if necessary?
    N. A.
    JIRA TASK: [DALI-865]

@banasraf
Copy link
Collaborator Author

banasraf commented Nov 4, 2019

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [974591]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [974591]: BUILD FAILED

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
@banasraf
Copy link
Collaborator Author

banasraf commented Nov 4, 2019

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [974619]: BUILD STARTED

Rafal added 2 commits November 4, 2019 17:03
Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [974691]: BUILD STARTED

@banasraf banasraf changed the title [WIP] Add sequence and 3D support in flip operator Add sequence and 3D support in flip operator Nov 4, 2019
@banasraf banasraf requested review from mzient, jantonguirao and klecki and removed request for mzient and jantonguirao November 4, 2019 17:00
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [974619]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [974691]: BUILD PASSED

@@ -90,18 +99,19 @@ class DLL_PUBLIC FlipCPU {
public:
DLL_PUBLIC FlipCPU() = default;

DLL_PUBLIC KernelRequirements Setup(KernelContext &context, const InTensorCPU<Type, 4> &in) {
DLL_PUBLIC KernelRequirements Setup(KernelContext &context, const InTensorCPU<Type, 5> &in) {
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 put some meaningful name to this magic 5?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Rafal added 2 commits November 6, 2019 13:02
Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
@@ -23,6 +23,9 @@

namespace dali {
namespace kernels {

constexpr int sample_ndim = 5;
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 use this in all the places where there is a 5 hardcoded?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

detail::cpu::FlipImpl(out_data, in_data, in.shape[0], in.shape[1], in.shape[2], in.shape[3],
flip_z, flip_y, flip_x);
detail::cpu::FlipImpl(out_data, in_data,
in.shape[0], in.shape[1], in.shape[2], in.shape[3], in.shape[4],
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just pass in.shape ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, done

@@ -24,7 +24,7 @@ namespace dali {
namespace kernels {

class FlipCpuTest
: public::testing::TestWithParam<std::tuple<int, int, int, std::array<Index, 4>>> {
: public::testing::TestWithParam<std::tuple<int, int, int, std::array<Index, 5>>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

use sample_ndim

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

};

TEST_P(FlipCpuTest, ImplTest) {
std::vector<float> out_data(volume(shape_));
detail::cpu::FlipImpl(
out_data.data(), in_view_.data,
shape_[0], shape_[1], shape_[2], shape_[3],
shape_[0], shape_[1], shape_[2], shape_[3], shape_[4],
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering, is it possible to work with a shape or arbitrary size and a layout, so that we can get the relevant dimensions and set to 1 the rest of them (that is, inside the implementation)

@@ -23,7 +23,7 @@
namespace dali {
namespace kernels {

class FlipGpuTest: public testing::TestWithParam<std::array<Index, 4>> {
class FlipGpuTest: public testing::TestWithParam<std::array<Index, 5>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

sample_ndim

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -36,7 +39,7 @@ inline int GetOcvType(size_t channels) {

template <typename Type>
void OcvFlip(Type *output, const Type *input,
size_t layers, size_t height, size_t width, size_t channels,
size_t depth, size_t height, size_t width, size_t channels,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why? And what about frames?

Copy link
Collaborator Author

@banasraf banasraf Nov 12, 2019

Choose a reason for hiding this comment

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

Why?
depth seems a better name along with height and width.
What about frames?
Do we want to flip the order of frames?

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
@banasraf
Copy link
Collaborator Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [988584]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [988584]: BUILD PASSED

@banasraf banasraf merged commit 5571413 into NVIDIA:master Nov 13, 2019
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