-
Notifications
You must be signed in to change notification settings - Fork 615
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
Warp 3D #1442
Warp 3D #1442
Conversation
!build |
CI MESSAGE: [976711]: BUILD STARTED |
CI MESSAGE: [976711]: BUILD FAILED |
!build |
CI MESSAGE: [977970]: BUILD STARTED |
CI MESSAGE: [977970]: BUILD FAILED |
!build |
CI MESSAGE: [978394]: BUILD STARTED |
CI MESSAGE: [978394]: BUILD FAILED |
!build |
CI MESSAGE: [980166]: BUILD STARTED |
CI MESSAGE: [980166]: BUILD PASSED |
@@ -66,6 +66,68 @@ TEST(GeomTransform, Rotation2D) { | |||
EXPECT_NEAR(rotated4.y, 0, 1e-6f); | |||
} | |||
|
|||
struct vec_near { | |||
template <int N, typename T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this only makes sense for floating point types, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, you can have some tolerance even for integer types - but here it's used only for floats.
dali/kernels/common/block_setup.h
Outdated
|
||
for (;;) { | ||
auto block_vol = volume(ret); | ||
if (block_vol <= 0x40000 || (sample_vol / block_vol) > 256) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (block_vol <= 0x40000 || (sample_vol / block_vol) > 256) | |
if (block_vol <= max_block_elements_ || (sample_vol / block_vol) > 256) |
const InTensorCPU<InputType, 4> &input, | ||
Mapping_ &mapping, | ||
BorderType border = {}) { | ||
int out_w = output.shape[2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: would make more sense to have those in order
const InTensorCPU<InputType, 4> &input, | ||
AffineMapping<3> &mapping, | ||
BorderType border = {}) { | ||
int out_w = output.shape[2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
setup.SetDefaultBlockSize(def_block_size); | ||
static_assert(setup.tensor_ndim == 4, "Incorrectly inferred tensor_ndim"); | ||
setup.SetupBlocks(TLS); | ||
ASSERT_TRUE(setup.IsUniformSize()); | ||
|
||
while (volume(def_block_size) > 0x40000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0x40000
should better be a named constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a good unit test, because it's actually testing the implementation. In such cases, I'd even say I like magic constants in tests - at least everything is clearly visible, not hidden behind layers of meaningless names. I removed the magic value from Setup though.
@@ -20,7 +20,9 @@ DALI_SCHEMA(Rotate) | |||
.DocStr(R"code(Rotate the image by given angle.)code") | |||
.NumInput(1) | |||
.NumOutput(1) | |||
.InputLayout(0, { "HWC" }) | |||
.InputLayout(0, { "HWC", "DHWC" }) | |||
.AddOptionalArg<float>("axis", "3D only: axis aroun which to rotate; alternatively, Euler angles " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.AddOptionalArg<float>("axis", "3D only: axis aroun which to rotate; alternatively, Euler angles " | |
.AddOptionalArg<float>("axis", "3D only: axis around which to rotate; alternatively, Euler angles " |
.InputLayout(0, { "HWC" }) | ||
.InputLayout(0, { "HWC", "DHWC" }) | ||
.AddOptionalArg<float>("axis", "3D only: axis aroun which to rotate; alternatively, Euler angles " | ||
"(yaw, pitch, roll) can be used", std::vector<float>(), true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem to be true
docs/examples/index.rst
Outdated
@@ -9,6 +9,7 @@ Tutorials | |||
detection_pipeline.ipynb | |||
augmentation_gallery.ipynb | |||
warp.ipynb | |||
3D.ipynb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe rename this file to warp_3d
as we might want to have other 3d notebooks later
!build |
CI MESSAGE: [981878]: BUILD STARTED |
CI MESSAGE: [981878]: BUILD PASSED |
3c89a88
to
7201cf3
Compare
!build |
CI MESSAGE: [981986]: BUILD STARTED |
!build |
CI MESSAGE: [981995]: BUILD STARTED |
!build |
CI MESSAGE: [982002]: BUILD STARTED |
CI MESSAGE: [982002]: BUILD PASSED |
block.start.y = blockIdx.y * block_size.y; | ||
ivec<ndim> block_idx(0); | ||
block_idx.x = blockIdx.x; | ||
block_idx.y = blockIdx.y; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assume that ndim > 2
and we have block_idx.y
and block_idx[2]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we can't.
if (z_blocks_per_sample_shift) { | ||
block.sample_idx = blockIdx.z >> z_blocks_per_sample_shift; | ||
int block_in_sample = blockIdx.z & ((1 << z_blocks_per_sample_shift) - 1); | ||
block_idx[2] = block_in_sample; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not block_idx.z
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
: public WarpParamProvider<Backend, 2, RotateParams<2>, BorderType> { | ||
inline TensorShape<3> RotatedCanvasSize(TensorShape<3> input_shape, vec3 axis, double angle) { | ||
ivec3 in_size = kernels::shape2vec(input_shape); | ||
float eps = 1e-2f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constexpr?
@@ -141,8 +188,42 @@ class RotateParamProvider<Backend, 2, BorderType> | |||
} | |||
} | |||
|
|||
template <int N, typename T> | |||
void Collect(std::vector<vec<N, T>> &v, const std::string &name, bool required) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move to some utils? It may be reused by other ops as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In another PR maybe...
qa/TL1_jupyter_plugins/test.sh
Outdated
@@ -1,7 +1,7 @@ | |||
#!/bin/bash -e | |||
|
|||
# used pip packages | |||
pip_packages="jupyter matplotlib mxnet-cu{cuda_v} tensorflow-gpu torchvision torch" | |||
pip_packages="jupyter matplotlib mxnet-cu{cuda_v} tensorflow-gpu torchvision torch opencv-python" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need it here.
qa/TL1_jupyter_notebooks_TU/test.sh
Outdated
@@ -1,7 +1,7 @@ | |||
#!/bin/bash -e | |||
|
|||
# used pip packages | |||
pip_packages="jupyter matplotlib numpy" | |||
pip_packages="jupyter matplotlib numpy opencv-python" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need it here.
qa/TL1_jupyter_multigpu/test.sh
Outdated
@@ -1,7 +1,7 @@ | |||
#!/bin/bash -e | |||
|
|||
# used pip packages | |||
pip_packages="jupyter matplotlib numpy" | |||
pip_packages="jupyter matplotlib numpy opencv-python" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need it here.
docs/examples/warp_3D.ipynb
Outdated
"source": [ | ||
"## Usage example\n", | ||
"\n", | ||
"First, let's import the necessary modules and define the location of the dataset." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and define the location of the dataset.
I think is it not done here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True.
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Fix block size issues. Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Add 3D.ipynb to index.rst. Add opencv-python to jupyter tests. Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Added ability to split uniformly sized samples along Z axis (by a pow2 factor). Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
!build |
CI MESSAGE: [986757]: BUILD STARTED |
CI MESSAGE: [986757]: BUILD FAILED |
CI MESSAGE: [986820]: BUILD STARTED |
CI MESSAGE: [986820]: BUILD PASSED |
Why we need this PR?
Pick one
What happened in this PR?
JIRA TASK: [DALI-don't-remember]