glow icon indicating copy to clipboard operation
glow copied to clipboard

Load an onnx model with ConvTranspose2d group > 1

Open sheh opened this issue 5 years ago • 3 comments

Original discussion

A pretrained model has the following layer

nn.ConvTranspose2d(64, 64, kernel_size=2, stride=2, 
    padding=0, output_padding=0, groups=64, bias=False)

the model was converted to onnx.

During compilation using command:

./build/bin/model-compiler -g -model model.onnx -emit-bundle ./bundle -backend=CPU

an assertion fails:

assert(filterDims.n % group == 0 && filterDims.h == kdim.height && 
filterDims.w == kdim.width && filterDims.c == idim.c / group && "Invalid filter dims"); 

for my case:

idim = (1, 64, 15, 20) 
filterDims = (64, 1, 2, 2) 
group = 64

so filterDims.n % group != 0 and filterDims.c != idim.c / group.

The assertion is passed only with group = 1.

What wrong with the layer parameters and what the assertion checks?

glow commit: 43b5e0de684f863134d2740e1b8a76c2613d5db0
pytorch commit: b2cc9928dd413ccc7b85315b1a9ed9e01f58a6eb

sheh avatar May 14 '20 14:05 sheh

CC: @vuzelac-cadence

jfix71 avatar May 28 '20 21:05 jfix71

@sheh , your input idim = (1, 64, 15, 20) suggests NCHW. Glow is NHWC. So I assume asserts gets triggered since idim.c = 20. Also, not sure if you want to use CPU/Interpreter backends, but those support group=1 only. If you can please share your model.

vuzelac-cadence avatar May 28 '20 23:05 vuzelac-cadence

Hey, @vuzelac-cadence I am also getting the same error for similar inputs. Activation: [1,64,20,20] Weights=[64,1,2,2] stride=[2,2] group=64

I think the problem that you were suspecting idim.c=20 is not a problem as it is transposed by ONNXModelLoader to become [1,15,20,64] and then it is not the problem.

Error is coming from filterDims.n % group != 0 and filterDims.c != idim.c / group, as filterDims.n==1 and filterDims.c==64 in our case. Mostly this error is coming from wrong transpose of filter in ONNXModelLoader.

garg1himanshu avatar Jul 17 '20 04:07 garg1himanshu