[TOPI] Depthwise conv2d config application error


#1

According to [SOLVED] KeyError: 'tile_ic' when tuning MobileNet, I found this should be considered as a bug.

The reason of this KeyError is because depthwise conv2d has no tuning space by default. This is not a problem for AutoTVM since it just tunes nothing. However, when we try to apply the best history, it falls here:

1.     cfg = dispatch_ctx.query(target, workload)
2.     if cfg.is_fallback:
3.         if _is_int8_hw_support(data_dtype, kernel_dtype):
4.             _get_default_config_int8(cfg, data_tensor, kernel_tensor, strides, padding, out_dtype,
5.                                      is_depthwise, data_layout)
6.         else:
7.             _get_default_config(cfg, data_tensor, kernel_tensor, strides, padding, out_dtype,
8.                                 is_depthwise, data_layout)
9.     # Get the tiling parameters to set the layout names.
10.     ic_bn, oc_bn = cfg["tile_ic"].size[-1], cfg["tile_oc"].size[-1]

If cfg comes from the tuning history, then it has no config in the case of depthwise conv2d. Even worst, it is not a fallback config, so line 4 or line 7 won’t be triggered and the key error happens at line 10.

We may have a quick fix that checks if all required entries are available; otherwise we enforce the fallback config.

cc @kevinthesun