krishnaraj36 commented on code in PR #15786: URL: https://github.com/apache/tvm/pull/15786#discussion_r1375672937
########## python/tvm/topi/adreno/conv2d_transpose_nchw.py: ########## @@ -0,0 +1,383 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# pylint: disable=invalid-name,unused-variable,unused-argument,no-else-return +"""conv2d_transpose nchw schedule on Qualcomm Adreno GPU""" +import tvm +from tvm import te +from tvm import autotvm +from .. import nn + + +from ..utils import get_const_tuple, traverse_inline +from .utils import ( + split_to_chunks, + pack_input, + pack_filter, + bind_data_copy, + get_default_conv2d_config, + get_texture_storage, +) + + [email protected]_topi_compute("conv2d_transpose_nchwc.image2d") +def conv2d_transpose_nchwc( + cfg, Input, Filter, stride, padding, out_dtype, output_padding, groups=1 +): + """ + Transposed Convolution operator in NCHWc layout. + Algo: Review Comment: I have added the description of algorithm. Thanks for review. ########## python/tvm/relay/op/strategy/adreno.py: ########## @@ -215,6 +215,58 @@ def conv2d_winograd_without_weight_transform_strategy_adreno(attrs, inputs, out_ return strategy +@conv2d_transpose_strategy.register("adreno") +def conv2d_transpose_strategy_adreno(attrs, inputs, out_type, target): + """conv2d_transpose adreno strategy""" + strategy = _op.OpStrategy() + _, kernel = inputs + dilation = attrs.get_int_tuple("dilation") + groups = attrs.groups + data_layout = attrs.data_layout + kernel_layout = attrs.kernel_layout + assert dilation == (1, 1), "not support dilate now" + + if (groups == 1) and ( + (data_layout == "NCHW" and kernel_layout == "IOHW") + or (data_layout == "NCHW4c" and kernel_layout == "IOHW4o") + or (data_layout == "NCHW" and kernel_layout == "IOHW4o") + ): + if len(kernel.shape) == 4: + oc, _, _, _ = get_const_tuple(kernel.shape) + else: + oc, _, _, _, _ = get_const_tuple(kernel.shape) + # We cannot use textures for case than number of channels is less than 4. + # So, we use compute functions from cuda. + if len(kernel.shape) == 4 and oc < 4: + strategy.add_implementation( + wrap_compute_conv2d_transpose(topi.cuda.conv2d_transpose_nchw), + wrap_topi_schedule(topi.cuda.schedule_conv2d_transpose_nchw), + name="conv2d_transpose_nchw.cuda", + ) + return strategy Review Comment: When the number of channels is less than 4, the repacking is not happening, and it raises the runtime failures. This is known existing issue all conv2d operators in tvm. So we are bypassing to cuda schedule. Thanks for review -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
