-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[RELAY][OP] Dynamic conv2d batch size for cuda #6598
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -302,6 +302,15 @@ def nhwc_winograd_cuda( | |
| tile_size = _infer_tile_size(data, kernel) | ||
| N, H, W, CI = get_const_tuple(data.shape) | ||
|
|
||
| if isinstance(N, tvm.tir.Any): | ||
| N = tvm.te.size_var("n") | ||
|
|
||
| if not isinstance(H, int) or not isinstance(W, int): | ||
| raise RuntimeError( | ||
| "cuda winograd nhwc conv2d doesn't support dynamic \ | ||
| input height or width." | ||
| ) | ||
|
|
||
| if isinstance(dilation, int): | ||
| dilation_h = dilation_w = dilation | ||
| else: | ||
|
|
@@ -330,7 +339,7 @@ def nhwc_winograd_cuda( | |
| H = (H + pt + pb - KH) // HSTR + 1 | ||
| W = (W + pl + pr - KW) // WSTR + 1 | ||
| nH, nW = (H + m - 1) // m, (W + m - 1) // m | ||
| P = N * nH * nW | ||
| P = N * nH * nW if isinstance(N, int) else nH * nW | ||
|
|
||
| # Determine whether the shape is available with tensorcore | ||
| shape_judge = ( | ||
|
|
@@ -432,7 +441,8 @@ def nhwc_winograd_cuda( | |
| name="output", | ||
| tag="conv2d_nhwc_winograd", | ||
| ) | ||
| cfg.add_flop(2 * N * CO * H * W * CI * KH * KW) | ||
| if isinstance(N, int): | ||
| cfg.add_flop(2 * N * CO * H * W * CI * KH * KW) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kevinthesun @icemelon9 @comaniac is this okay to autotvm?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's okay in terms of the functionality, but the output message would be weird. Since the AutoTVM progress bar shows throughput instead of latency, users will always see 0 GFLOPS during the tuning process (https://github.com/apache/incubator-tvm/blob/master/python/tvm/autotvm/tuner/callback.py#L159). Maybe we can still have the FLOPS with N=1 and pop a message saying we are tuning the kernel with N=1 but it can be used by the kernel with any batch size?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I thought about 1 as well. But it actually maybe not 1
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine since generally AutoTVM can't be used for dynamic shape op. User won't see any flops info when N is symbolic. |
||
| return output | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.