Menooker commented on pull request #5357:
URL: https://github.com/apache/incubator-tvm/pull/5357#issuecomment-621567041
> @Menooker Could you share the script that can reproduce the error? It's a
bit weird that `_alter_conv2d_layout` receive a conv2d op with `NCHWc` layout.
My usecase is that, I want to use `nn.conv2d` with "NCHWc' layout in the
frontend. I noticed that there are `relay.nn.contrib_conv2d_nchwc` and
`contrib_depthwise_conv2d_nchwc`. I think users do not need to choose from
`conv2d_nchwc` and `depthwise_conv2d_nchwc` manually. And I want TVM to decide
which to use automatically - just like what TVM is now doing on `conv2d` with
"NCHW'. So I use "NCHW16c" in `nn.conv2d`:
```python
from tvm import relay
import tvm
img = relay.var("img", shape=(128, 3, 224, 224, 1), dtype='float')
weight = relay.var("weight", shape=(1, 3, 3, 3, 1, 16 ), dtype='float')
conv = relay.nn.conv2d(img, weight, strides=(2, 2), padding=(1, 1),
dilation=(1, 1), groups=1, channels=16, kernel_size=[3, 3],
data_layout='NCHW1c', kernel_layout='OIHW1i16o', out_layout='NCHW16c')
func = relay.Function([img, weight], conv)
target = 'llvm -mcpu=skylake-avx512'
ctx = tvm.context(target, 0)
print(func)
with relay.build_config(opt_level=3):
graph, lib, params_fwd = relay.build(func, target)
```
Supporting "NCHWc" in `nn.conv2d` will make the frontend cleaner: users can
use `nn.conv2d` for depthwise or not, and blocking format or not. TVM will
choose the implementation (like `depthwise_conv2d_nchwc`) under the hood.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]