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

Bilinear mode in topi::nn::upsampling not working #1692

Closed
ke1337 opened this issue Sep 7, 2018 · 11 comments
Closed

Bilinear mode in topi::nn::upsampling not working #1692

ke1337 opened this issue Sep 7, 2018 · 11 comments

Comments

@ke1337
Copy link
Contributor

ke1337 commented Sep 7, 2018

To repro, use following changes in test_topi_upsampling.py:

--- a/topi/tests/python/test_topi_upsampling.py
+++ b/topi/tests/python/test_topi_upsampling.py
@@ -22,7 +22,7 @@ def verify_upsampling(batch, in_channel, in_height, in_width, scale, layout='NCH
         raise NotImplementedError(
             'Layout not supported {} '.format(layout))

-    B = topi.nn.upsampling(A, scale, layout=layout)
+    B = topi.nn.upsampling(A, scale, layout=layout, method='BILINEAR')

     b_np = topi.testing.upsampling_python(a_np, scale, layout)
@masahi
Copy link
Member

masahi commented Sep 9, 2018

cc @srkreddy1238

@srkreddy1238
Copy link
Contributor

@KeDengMS

NCH layout ???
Can you conform the error log ?

@ke1337
Copy link
Contributor Author

ke1337 commented Sep 10, 2018

Yes NCHW layout, but I believe it exists in NHWC as well. The error is from a crash in dereferencing nullptr in here. The problem is that shape is a Mul node with two IntImm as input from the python API, and as_const_int returns nullptr for non-const node.
It seems const folding should be applied, and moreover the bilinear interpolation code path needs to be tested.

@srkreddy1238
Copy link
Contributor

@KeDengMS a bit confused.

Is the issue about "Layout Not Supported" or "Crash " ?

Can you share complete log or the sample code?

@ke1337
Copy link
Contributor Author

ke1337 commented Sep 11, 2018

I think it's nothing about Layout, but more for BILINEAR mode. The repro is to change the python test to use BILINEAR mode: B = topi.nn.upsampling(A, scale, layout=layout, method='BILINEAR'), then you'll find the crash.

@masahi
Copy link
Member

masahi commented Sep 12, 2018

But the log says NotImplementedError('Layout not supported {} '.format(layout)). What is the "layout" parameter you passed in? It should be "NCHW" or "NHWC".

@ke1337
Copy link
Contributor Author

ke1337 commented Sep 12, 2018

The repro I show above is from git diff, not the log. The testcase tests both NCHW and NHWC

@masahi
Copy link
Member

masahi commented Sep 12, 2018

@KeDengMS I can repro your crash. The fix is to add util.simplify to https://github.com/dmlc/tvm/blob/master/topi/python/topi/nn/upsampling.py#L34
This is equivalent to const folding you mentioned.

I can send a PR to fix this and update the upsampling test.

@masahi
Copy link
Member

masahi commented Sep 12, 2018

@srkreddy1238 I made a branch to fix this issue here. But some bilinear upsampling tests are failing. Can you have a look?

@srkreddy1238
Copy link
Contributor

Thanks @KeDengMS for bringing up the issue and thanks @masahi for finding the root cause and fix.
I have added the final piece (atol=1e-5 allowance) at #1708 for your review comment.

@ke1337
Copy link
Contributor Author

ke1337 commented Sep 12, 2018

Thanks for the fix!

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

No branches or pull requests

3 participants