Deformable conv implementations differences between pytorch torhcvision & tvm

I’m trying to convert torchvision dcn to tvm dcn. However, with the same inputs, i couldn’t get same output from torchvision dcn and tvm dcn.

I tried 2 versions of pytorch dcn implementation, torchvision & mmcv, get the sample outputs with the same inputs(data, offset, weight). But, results from relay.nn.deformable_conv2d and torchvision.ops.DeformConv2d are not the same.

test codes can be find here. Results of the above test codes are

deformable_conv2d is not optimized for this platform.
pytorch torchvision res & tvm relay res 10.931563
mmcv dcn vs torchvision dcn 0.0
1 Like

The input name to set_input shouldn’t be 0, 1 etc, but the corresponding variable names like “data”, “weight”, “offset”, “input0” etc. Can you try if this change gets the correct output?

Still get different results.

I’m not familiar with relay, correct me if i make rookie mistakes. In my sample code, data is input, bias & weight are params, so m.set_input('data', ...) is enough.

PS: I use offset = relay.var("bias", ...) instead of offset = relay.var("offset", ...) because of ValueError: Unknown initialization pattern for offset, hope this won’t cause this issue.

Try to use mxnet dcn, it turns out that tvm & mxnet dcn have the same results.

Codes can be find https://github.com/irvingzhang0512/tvm_tests/blob/master/dcn/dcn_tests.py

deformable_conv2d is not optimized for this platform.
pytorch torchvision dcn vs tvm relay dcn 10.221999
mmcv dcn vs torchvision dcn  0.0
mxnet dcn vs torchvision dcn  10.221999
mxnet dcn vs tvm relay dcn  4.7683716e-06

Yes, I remember TVM’s implementation of deformable conv is modeled after MXNet.

Have you found the reason? I have the same issue ! How did you solve it? Thank you very much!