Commit 68472596 by Animesh Jain Committed by Zhi

[Relay][Topi] Disable conv NHWC pack int8. (#4038)

parent 481b9c49
......@@ -93,9 +93,25 @@ def test_compile_full():
relay.build(mod, 'llvm')
def test_compile_nhwc_pack():
data = relay.var("data", shape=(1, 1, 1, 1024), dtype="uint8")
weight = relay.var("weight", shape=(1, 1, 1024, 1001), dtype="int8")
p2 = relay.var("p2", shape=(1, 1, 1, 1), dtype="int32")
conv = relay.nn.conv2d(data, weight, kernel_size=(1, 1), data_layout="NHWC",
kernel_layout="HWIO", out_dtype="int32")
multiply = relay.multiply(relay.const(-22, dtype='int32'), p2)
tile = relay.tile(multiply, reps=(1, 1, 1, 1001))
subtract = relay.subtract(conv, tile)
func = subtract
mod = relay.Function(relay.analysis.free_vars(func), func)
relay.build(mod, target="llvm")
if __name__ == "__main__":
test_compile_engine()
test_compile_placeholder_bypass()
test_compile_injective_with_tuple()
test_compile_tuple_dup()
test_compile_full()
test_compile_nhwc_pack()
......@@ -110,12 +110,15 @@ def _declaration_conv(cfg, data, kernel, strides, padding, dilation, layout, out
kh, kw, _, _ = get_const_tuple(kernel.shape)
if layout == 'HWCN':
return nn.conv2d_hwcn(data, kernel, strides, padding, dilation, out_dtype)
elif layout == 'NHWC' and kh == 1 and kw == 1 and kernel.dtype == "int8":
if cfg.is_fallback:
_get_default_config(cfg, data, kernel, strides, padding, out_dtype, False, layout)
# specialize for INT8 1X1 conv on X86
return conv2d_avx_1x1._declaration_conv_nhwc_pack(cfg, data, kernel, strides,
padding, dilation, out_dtype)
# FIXME - https://github.com/dmlc/tvm/issues/4122
# _declaration_conv_nhwc_pack expects kernel layout to be HWOI. However, the tests use HWIO
# layout. Commenting until we have clarity about the nhwc_pack implementation from the author.
# elif layout == 'NHWC' and kh == 1 and kw == 1 and kernel.dtype == "int8":
# if cfg.is_fallback:
# _get_default_config(cfg, data, kernel, strides, padding, out_dtype, False, layout)
# # specialize for INT8 1X1 conv on X86
# return conv2d_avx_1x1._declaration_conv_nhwc_pack(cfg, data, kernel, strides,
# padding, dilation, out_dtype)
elif layout == 'NHWC':
return nn.conv2d_nhwc(data, kernel, strides, padding, dilation, out_dtype)
raise ValueError("not support this layout {} yet".format(layout))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment