Cannot store type float32 for fusion of bn and relu
I am trying to add the fusion of bn and relu for the depthwise conv forward for layout NHWC. When I try to build the bn with the s2 scheduler, it does not work. f2 = tvm.build(s2, [Input, Filter, Scale, Shift, ScaleShift], device) In the same test file, the depthwise conv forward test for both NHWC and NCHW passed. The bn and relu fusion for NCHW also passes. Am I missing something for NHWC layout with the fusion?
Traceback (most recent call last):
File "test_topi_depthwise_conv2d_map.py", line 215, in
The code I modify from is this: https://github.com/dmlc/tvm/blob/master/topi/tests/python/test_topi_depthwise_conv2d_map.py Thank you!
can you paste a copy of ir after tvm.lower?
It seems it does not do the compute-inline. But it does get into this line of traverse (nhwc version): https://github.com/dmlc/tvm/blob/master/topi/python/topi/cuda/depthwise_conv2d_map.py#L107
Does the scale shift and relu also has layout to be considered? // attr [DepthwiseConv2d] storage_scope = "global" allocate DepthwiseConv2d[float32 * 1 * 64 * 64 * 728] produce DepthwiseConv2d { // attr [iter_var(blockIdx.x, , blockIdx.x)] thread_extent = 1024 // attr [Filter.shared] storage_scope = "shared" allocate Filter.shared[float32 * 3 * 3 * 728 * 1] produce Filter.shared { for (ax0, 0, 3) { for (ax1, 0, 3) { // attr [iter_var(threadIdx.x, , threadIdx.x)] thread_extent = 728 Filter.shared[((((ax0*3) + ax1)728) + threadIdx.x)] = Filter[(((((blockIdx.x/1024)728) + (ax02184)) + (ax1728)) + threadIdx.x)] } } } for (i.inner, 0, 2) { for (j.inner, 0, 2) { // attr [iter_var(threadIdx.x, , threadIdx.x)] thread_extent = 728 DepthwiseConv2d[(((((((blockIdx.x/1024)*728) + (((blockIdx.x % 1024) % 32)1456)) + (((blockIdx.x % 1024)/32)93184)) + (i.inner46592)) + (j.inner728)) + threadIdx.x)] = 0.000000f for (di, 0, 3) { for (dj, 0, 3) { DepthwiseConv2d[(((((((blockIdx.x/1024)*728) + (((blockIdx.x % 1024) % 32)1456)) + (((blockIdx.x % 1024)/32)93184)) + (i.inner46592)) + (j.inner728)) + threadIdx.x)] = (DepthwiseConv2d[(((((((blockIdx.x/1024)*728) + (((blockIdx.x % 1024) % 32)1456)) + (((blockIdx.x % 1024)/32)93184)) + (i.inner46592)) + (j.inner728)) + threadIdx.x)] + (select(((((((1 - di) - i.inner) <= (((blockIdx.x % 1024)/32)*2)) && ((((blockIdx.x % 1024)/32)*2) < ((65 - di) - i.inner))) && (((1 - dj) - j.inner) <= (((blockIdx.x % 1024) % 32)*2))) && ((((blockIdx.x % 1024) % 32)2) < ((65 - dj) - j.inner))), Input[((((((((((blockIdx.x % 1024) % 32)1456) + (((blockIdx.x % 1024)/32)93184)) + (i.inner46592)) + (j.inner728)) + (((blockIdx.x/1024)728) + threadIdx.x)) + (di46592)) + (dj728)) + -47320)], 0.000000f)Filter.shared[((((((blockIdx.x/1024)728) + threadIdx.x) + (di2184)) + (dj728)) - ((blockIdx.x/1024)728))])) } } } } } produce ScaleShift { for (c, 0, 64) { for (i, 0, 64) { for (j, 0, 728) { ScaleShift[((((c64) + i)728) + j)] = ((DepthwiseConv2d[((((c64) + i)*728) + j)]*Scale[c]) + Shift[c]) } } } }
@tqchen The problem is that scale shift supports only NCHW layout. I will add another layout to it. Thank you!
Unfortunately, the problem remains. Here is the tvm.lower:
// attr [DepthwiseConv2d] storage_scope = "global" allocate DepthwiseConv2d[float32 * 1 * 64 * 64 * 728] produce DepthwiseConv2d { // attr [iter_var(blockIdx.x, , blockIdx.x)] thread_extent = 1024 // attr [Filter.shared] storage_scope = "shared" allocate Filter.shared[float32 * 3 * 3 * 728 * 1] produce Filter.shared { for (ax0, 0, 3) { for (ax1, 0, 3) { // attr [iter_var(threadIdx.x, , threadIdx.x)] thread_extent = 728 Filter.shared[((((ax0*3) + ax1)728) + threadIdx.x)] = Filter[(((((blockIdx.x/1024)728) + (ax02184)) + (ax1728)) + threadIdx.x)] } } } for (i.inner, 0, 2) { for (j.inner, 0, 2) { // attr [iter_var(threadIdx.x, , threadIdx.x)] thread_extent = 728 DepthwiseConv2d[(((((((blockIdx.x/1024)*728) + (((blockIdx.x % 1024) % 32)1456)) + (((blockIdx.x % 1024)/32)93184)) + (i.inner46592)) + (j.inner728)) + threadIdx.x)] = 0.000000f for (di, 0, 3) { for (dj, 0, 3) { DepthwiseConv2d[(((((((blockIdx.x/1024)*728) + (((blockIdx.x % 1024) % 32)1456)) + (((blockIdx.x % 1024)/32)93184)) + (i.inner46592)) + (j.inner728)) + threadIdx.x)] = (DepthwiseConv2d[(((((((blockIdx.x/1024)*728) + (((blockIdx.x % 1024) % 32)1456)) + (((blockIdx.x % 1024)/32)93184)) + (i.inner46592)) + (j.inner728)) + threadIdx.x)] + (select(((((((1 - di) - i.inner) <= (((blockIdx.x % 1024)/32)*2)) && ((((blockIdx.x % 1024)/32)*2) < ((65 - di) - i.inner))) && (((1 - dj) - j.inner) <= (((blockIdx.x % 1024) % 32)*2))) && ((((blockIdx.x % 1024) % 32)2) < ((65 - dj) - j.inner))), Input[((((((((((blockIdx.x % 1024) % 32)1456) + (((blockIdx.x % 1024)/32)93184)) + (i.inner46592)) + (j.inner728)) + (((blockIdx.x/1024)728) + threadIdx.x)) + (di46592)) + (dj728)) + -47320)], 0.000000f)Filter.shared[((((((blockIdx.x/1024)728) + threadIdx.x) + (di2184)) + (dj728)) - ((blockIdx.x/1024)728))])) } } } } } produce ScaleShift { for (i, 0, 64) { for (j, 0, 64) { for (c, 0, 728) { ScaleShift[((((i64) + j)728) + c)] = ((DepthwiseConv2d[((((i64) + j)*728) + c)]*Scale[c]) + Shift[c]) } } } }
Thank you!
This is because the schedule does not successfully fused the compute into scaleshift, and schedule shift computation becomes CPU computation