Skip to content

Added GPU implementation for resize nearest neighbor. - #588

Closed
panmari wants to merge 1 commit into
tensorflow:masterfrom
panmari:gpu_resize_nn
Closed

panmari wants to merge 1 commit into
tensorflow:masterfrom
panmari:gpu_resize_nn

Conversation

@panmari

@panmari panmari commented Dec 22, 2015

Copy link
Copy Markdown
Contributor

Also added appropriate tests/benchmarks. Implementation for backwards step is still missing and will follow in another PR. I tried to model it after the code used for maxpooling.

@panmari

panmari commented Dec 23, 2015

Copy link
Copy Markdown
Contributor Author

Rebased again on master due to changes in tensorflow/python/ops/image_ops_test.py

@panmari
panmari force-pushed the gpu_resize_nn branch 2 times, most recently from 68641d6 to 8dae17a Compare January 4, 2016 12:41
@panmari

panmari commented Jan 7, 2016

Copy link
Copy Markdown
Contributor Author

@martinwicke could I please get some feedback on this?

@tensorflow-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@martinwicke

Copy link
Copy Markdown
Member

Jenkins, test this please.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you indent this to 4 below the indent of OP_REQUIRES_OK? Similar to line 229 below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@martinwicke

Copy link
Copy Markdown
Member

Assuming the tests pass, LGTM.

@martinwicke

Copy link
Copy Markdown
Member

That is, after the line comment.

@vrv

vrv commented Jan 11, 2016

Copy link
Copy Markdown

Cool, can you squash your commits? We'll use this change as a way to test our eventual GPU test slave, maybe.

@panmari

panmari commented Jan 11, 2016

Copy link
Copy Markdown
Contributor Author

@vrv rebased on master and squashed, as requested.

@martinwicke

Copy link
Copy Markdown
Member

Thanks! I'll wait to test until our GPU test machine comes online to test this. Should be today, I hope.

@martinwicke

Copy link
Copy Markdown
Member

Sorry this is taking so long. Hardware is hard.

@panmari

panmari commented Jan 15, 2016

Copy link
Copy Markdown
Contributor Author

💻 🔨 ?

😄

@martinwicke

Copy link
Copy Markdown
Member

Jenkins, test this please.

@panmari

panmari commented Jan 25, 2016

Copy link
Copy Markdown
Contributor Author

Rebased on master again.

@martinwicke

Copy link
Copy Markdown
Member

Jenkins, test this please.

@tensorflow-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@vrv

vrv commented Feb 16, 2016

Copy link
Copy Markdown

doh, port.h was removed -- @panmari you'll probably have to update the code one more time :(

@martinwicke

Copy link
Copy Markdown
Member

On the plus side, we finally have working GPU tests now.

On Tue, Feb 16, 2016 at 1:42 PM Vijay Vasudevan [email protected]
wrote:

doh, port.h was removed -- @panmari https://github.com/panmari you'll
probably have to update the code one more time :(

—
Reply to this email directly or view it on GitHub
#588 (comment)
.

@panmari

panmari commented Feb 17, 2016

Copy link
Copy Markdown
Contributor Author

Sure, will do! I'd have to adapt the code anyway to support the new flag
introduced recently...

On Tue, Feb 16, 2016, 23:55 Martin Wicke [email protected] wrote:

On the plus side, we finally have working GPU tests now.

On Tue, Feb 16, 2016 at 1:42 PM Vijay Vasudevan [email protected]
wrote:

doh, port.h was removed -- @panmari https://github.com/panmari you'll
probably have to update the code one more time :(

—
Reply to this email directly or view it on GitHub
<
https://github.com/tensorflow/tensorflow/pull/588#issuecomment-184885352>
.

—
Reply to this email directly or view it on GitHub
#588 (comment)
.

@panmari

panmari commented Feb 18, 2016

Copy link
Copy Markdown
Contributor Author

I added another commit to support the newly added align_cornes flag and adapted some other things necessary. Unfortunately, on my local machine one of the tests in //tensorflow/python:image_ops_test is now failing. Could this be due to changes in the GPU allocator?

@vrv

vrv commented Feb 18, 2016

Copy link
Copy Markdown

What's the failure in particular?

@panmari

panmari commented Feb 19, 2016

Copy link
Copy Markdown
Contributor Author

@vrv in the test where I compare the cpu resizing with the gpu resizing, I get completely different results there even though the other tests pass

FAIL: testCompareNearestNeighbor (__main__.ResizeImagesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/panmari/.cache/bazel/_bazel_panmari/52e003c51984ee00b8d04ed6ebb99872/tensorflow/bazel-out/local_linux-opt/bin/tensorflow/python/image_ops_test.runfiles/tensorflow/python/ops/image_ops_test.py", line 990, in testCompareNearestNeighbor
    self.assertAllClose(cpu_val, gpu_val, rtol=1e-5, atol=1e-5)
  File "/home/panmari/.cache/bazel/_bazel_panmari/52e003c51984ee00b8d04ed6ebb99872/tensorflow/bazel-out/local_linux-opt/bin/tensorflow/python/image_ops_test.runfiles/tensorflow/python/framework/test_util.py", line 435, in assertAllClose
    np.testing.assert_allclose(a, b, rtol=rtol, atol=atol)
  File "/usr/local/lib/python2.7/dist-packages/numpy/testing/utils.py", line 1359, in assert_allclose
    verbose=verbose, header=header)
  File "/usr/local/lib/python2.7/dist-packages/numpy/testing/utils.py", line 713, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=1e-05, atol=1e-05

(mismatch 100.0%)
 x: array([[[[  0.,   1.,   2.],
         [  0.,   1.,   2.],
         [  3.,   4.,   5.],...
 y: array([[[[  5.903004e+20,   1.406543e+01,   4.097450e-34],
         [  5.903004e+20,   1.406543e+01,   4.097450e-34],
         [  5.903004e+20,   1.406543e+01,   4.097450e-34],...

----------------------------------------------------------------------
Ran 16 tests in 0.759s

FAILED (failures=1)
   1.50654290e-04   9.99999975e-06
   5.90300359e+15   1.50654290e-04   9.99999975e-06   5.90300359e+15
   1.50654290e-04   9.99999975e-06   5.90300359e+15   1.50654290e-04
   9.99999975e-06   5.90300359e+15   1.50654290e-04   9.99999975e-06
   5.90300359e+15   1.50654290e-04   9.99999975e-06   5.90300359e+15
   1.50654290e-04   9.99999975e-06   5.90300359e+15   1.50654290e-04
   9.99999975e-06   5.90300359e+15   1.50654290e-04   9.99999975e-06
   5.90300359e+15   1.50654290e-04   9.99999975e-06   5.90300359e+15
   1.50654290e-04   9.99999975e-06   5.90300359e+15   1.50654290e-04
   9.99999975e-06   5.90300359e+15   1.50654290e-04   9.99999975e-06]
area_ratio_hist  [ 70  73  90 100 133 154 162  95  80  43]

@vrv

vrv commented Feb 25, 2016

Copy link
Copy Markdown

@panmari: isn't that specifically the kernel you added that is showing different behavior between CPU and GPU? That probably needs to be fixed, unless I'm mis-reading the error.

@panmari

panmari commented Feb 29, 2016

Copy link
Copy Markdown
Contributor Author

@vrv sorry, it took some time until I got around fixing this. Seemed like np.float32 was interpreted differently due to some change since 0.6, leading to the failing test. I generalized my code a bit to make an extension to other types more easy.

For now only for float type. Also added appropriate tests where
necessary.
@vrv

vrv commented Mar 3, 2016

Copy link
Copy Markdown

@tensorflow-jenkins: test this please

(i swear, we'll get this in!)

vrv pushed a commit that referenced this pull request Mar 4, 2016
@vrv

vrv commented Mar 4, 2016

Copy link
Copy Markdown

Merged, woohoo!

@vrv vrv closed this Mar 4, 2016
@panmari

panmari commented Mar 4, 2016

Copy link
Copy Markdown
Contributor Author

Cool, glad it finally happened 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants