elvin-n commented on code in PR #11161:
URL: https://github.com/apache/tvm/pull/11161#discussion_r865792149
##########
src/runtime/opencl/opencl_common.h:
##########
@@ -345,6 +345,7 @@ struct BufferDescriptor {
* e.g. image2d[height=O, width=IHW]
*/
kImage2DWeight,
+ kTexture2DNHWC,
Review Comment:
Done
##########
python/tvm/relay/op/strategy/adreno.py:
##########
@@ -0,0 +1,162 @@
+# 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.
+"""Definition of adreno operator strategy."""
+# pylint:
disable=invalid-name,unused-argument,wildcard-import,unused-wildcard-import
+from tvm import topi
+from .generic import *
+from .. import op as _op
+
+
+@conv2d_NCHWc_strategy.register("adreno")
+@conv2d_strategy.register("adreno")
+def conv2d_strategy_adreno(attrs, inputs, out_type, target):
+ """conv2d adreno strategy"""
+ strategy = _op.OpStrategy()
+ data, kernel = inputs
+ dilation_h, dilation_w = attrs.get_int_tuple("dilation")
+ groups = attrs.groups
+ data_layout = attrs.data_layout
+ kernel_layout = attrs.kernel_layout
+ if dilation_h < 1 or dilation_w < 1:
+ raise ValueError("dilation should be positive value")
+
+ if groups == 1:
+ if (data_layout == "NCHW" and kernel_layout == "OIHW") or (
+ data_layout == "NCHW4c" and kernel_layout == "OIHW4o"
+ ):
+ if out_type.dtype == "float16":
+ strategy.add_implementation(
+ wrap_compute_conv2d(topi.adreno.conv2d_nchwc),
+ wrap_topi_schedule(topi.adreno.schedule_conv2d_nchwc),
+ name="conv2d_nchwc.image2d",
+ plevel=10,
+ )
+ strategy.add_implementation(
+ wrap_compute_conv2d(topi.adreno.conv2d_nchwc_acc32),
+ wrap_topi_schedule(topi.adreno.schedule_conv2d_nchwc_acc32),
+ name="conv2d_nchwc_tpack.image2d",
+ plevel=20,
+ )
+ elif (data_layout == "NHWC" and kernel_layout == "HWIO") or (
+ data_layout == "NHWC4c" and kernel_layout == "HWIO4o"
+ ):
+ if out_type.dtype == "float16":
+ strategy.add_implementation(
+ wrap_compute_conv2d(topi.adreno.conv2d_nhwc),
+ wrap_topi_schedule(topi.adreno.schedule_conv2d_nhwc),
+ name="conv2d_nhwc.image2d",
+ plevel=10,
+ )
+ strategy.add_implementation(
+ wrap_compute_conv2d(topi.adreno.conv2d_nhwc_acc32),
+ wrap_topi_schedule(topi.adreno.schedule_conv2d_nhwc_acc32),
+ name="conv2d_nhwc_acc32.image2d",
+ plevel=20,
+ )
+ else:
+ raise RuntimeError(
+ "Layout not supported: ("
+ + data_layout
+ + ", "
+ + kernel_layout
+ + ") - only support NCHW4c / OIHW4o and NHWC / HWOI layouts
for conv2d"
+ )
+ else:
+ # cannot use is_depthwise_conv2d because it does not know about
NHWC4c/HWOI4o layouts
+ if data_layout == "NCHW":
+ ic = data.shape[1]
+ elif data_layout == "NCHW4c":
+ ic = data.shape[1] * data.shape[4]
+ elif data_layout == "NHWC":
+ ic = data.shape[3]
+ elif data_layout == "NHWC4c":
+ ic = data.shape[3] * data.shape[4]
+ else:
+ # TODO(amalyshe) add proper error raising
Review Comment:
Done
--
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]