From 02381d075adeb37eba5670b54a83b424e720923d Mon Sep 17 00:00:00 2001 From: Andrey Malyshev Date: Wed, 31 Aug 2022 11:24:33 +0300 Subject: [PATCH] Fix AutoTVM flow --- python/tvm/topi/adreno/conv2d_nchw.py | 19 ++++++++++++------- python/tvm/topi/adreno/conv2d_nhwc.py | 19 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/python/tvm/topi/adreno/conv2d_nchw.py b/python/tvm/topi/adreno/conv2d_nchw.py index 2f8b4e0a128e..082f71364af8 100644 --- a/python/tvm/topi/adreno/conv2d_nchw.py +++ b/python/tvm/topi/adreno/conv2d_nchw.py @@ -274,13 +274,17 @@ def schedule_conv2d_NCHWc_KCRSk(cfg, s, output): # 3. If we have pad (independently if we have runtime repack or not) we should inline it in the # cache_read("texture") if autotvm.GLOBAL_SCOPE.in_tuning or input_pack_rt: - if "pad_temp" in pad_data.op.name: - pack_data = pad_data.op.input_tensors[0] - bind_data_copy(s[pack_data]) - s[pad_data].compute_inline() + if autotvm.GLOBAL_SCOPE.in_tuning: + if "pad_temp" in pad_data.op.name: + s[pad_data].compute_inline() else: - pack_data = pad_data - bind_data_copy(s[pack_data]) + if "pad_temp" in pad_data.op.name: + pack_data = pad_data.op.input_tensors[0] + bind_data_copy(s[pack_data]) + s[pad_data].compute_inline() + else: + pack_data = pad_data + bind_data_copy(s[pack_data]) AT = s.cache_read(pad_data, get_texture_storage(pad_data.shape), [conv]) bind_data_copy(s[AT]) @@ -291,7 +295,8 @@ def schedule_conv2d_NCHWc_KCRSk(cfg, s, output): bind_data_copy(s[AT]) if autotvm.GLOBAL_SCOPE.in_tuning or filter_pack_rt: - bind_data_copy(s[kernel]) + if not autotvm.GLOBAL_SCOPE.in_tuning: + bind_data_copy(s[kernel]) WT = s.cache_read(kernel, get_texture_storage(kernel.shape), [conv]) bind_data_copy(s[WT]) diff --git a/python/tvm/topi/adreno/conv2d_nhwc.py b/python/tvm/topi/adreno/conv2d_nhwc.py index ae75bff1e841..993b63252531 100644 --- a/python/tvm/topi/adreno/conv2d_nhwc.py +++ b/python/tvm/topi/adreno/conv2d_nhwc.py @@ -272,13 +272,17 @@ def schedule_conv2d_NHWC(cfg, s, output): # 3. If we have pad (independently if we have runtime repack or not) we should inline it in the # cache_read("texture") if autotvm.GLOBAL_SCOPE.in_tuning or input_pack_rt: - if "pad_temp" in pad_data.op.name: - s[pad_data].compute_inline() - pack_data = pad_data.op.input_tensors[0] - bind_data_copy(s[pack_data]) + if autotvm.GLOBAL_SCOPE.in_tuning: + if "pad_temp" in pad_data.op.name: + s[pad_data].compute_inline() else: - pack_data = pad_data - bind_data_copy(s[pack_data]) + if "pad_temp" in pad_data.op.name: + s[pad_data].compute_inline() + pack_data = pad_data.op.input_tensors[0] + bind_data_copy(s[pack_data]) + else: + pack_data = pad_data + bind_data_copy(s[pack_data]) AT = s.cache_read(pad_data, get_texture_storage(pad_data.shape), [conv]) bind_data_copy(s[AT]) @@ -289,7 +293,8 @@ def schedule_conv2d_NHWC(cfg, s, output): bind_data_copy(s[AT]) if autotvm.GLOBAL_SCOPE.in_tuning or filter_pack_rt: - bind_data_copy(s[kernel]) + if not autotvm.GLOBAL_SCOPE.in_tuning: + bind_data_copy(s[kernel]) WT = s.cache_read(kernel, get_texture_storage(kernel.shape), [conv]) bind_data_copy(s[WT])