Skip to content

Commit

Permalink
Added Limited Support for Adreno Texture Based Group Convolution (apa…
Browse files Browse the repository at this point in the history
…che#58)

This commit adds support for limited support for texture based group
convolution where the `in_channels` after accounting for `texture dim`
is divisible by `group size`. Otherwise, and if there was no extra
texture dim then it use default compute.
  • Loading branch information
Krishnaa, Sanjay authored and srkreddy1238 committed Aug 8, 2024
1 parent 1032151 commit 902a52b
Show file tree
Hide file tree
Showing 4 changed files with 625 additions and 1 deletion.
31 changes: 30 additions & 1 deletion python/tvm/relay/op/strategy/adreno.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,37 @@ def conv2d_strategy_adreno(attrs, inputs, out_type, target):
+ kernel_layout
+ ") - only support NCHW4c / OIHW4o and NHWC / HWOI layouts for conv2d"
)
elif (data_layout == "NCHW4c" or data_layout == "NCHW") and (
kernel_layout == "OIHW" or kernel_layout == "OIHW4o"
):
pad_in_chunks = (len(data.shape) == 5 and data.shape[1] % groups != 0) or (
len(data.shape) == 4 and data.shape[1] % (groups * 4) != 0
)
pad_out_chunks = (len(kernel.shape) == 5 and kernel.shape[0] % groups != 0) or (
len(kernel.shape) == 4 and kernel.shape[0] % (groups * 4) != 0
)

if not (pad_in_chunks or pad_out_chunks):
strategy.add_implementation(
wrap_compute_conv2d(topi.adreno.group_conv2d_nchwc),
wrap_topi_schedule(topi.adreno.schedule_group_conv2d_nchwc),
name="group_conv2d_nchwc.image2d",
plevel=10,
)
elif len(data.shape) == 4 and len(kernel.shape) == 4:
strategy.add_implementation(
wrap_compute_conv2d(topi.cuda.group_conv2d_nchw, has_groups=True),
wrap_topi_schedule(topi.cuda.schedule_group_conv2d_nchw),
name="group_conv2d_nchw.cuda",
)
else:
raise RuntimeError(
"General group convolution is not currently supported for NCHWc layouts"
)
else:
raise RuntimeError("General group convolution is not currently supported")
raise RuntimeError(
"General group convolution has limited support for NCHW(4c) layouts..."
)
return strategy


Expand Down
1 change: 1 addition & 0 deletions python/tvm/topi/adreno/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .conv2d_nchw import *
from .depthwise_conv2d_nchw import *
from .conv2d_nhwc import *
from .group_conv2d_nchw import *
from .depthwise_conv2d_nhwc import *
from .pooling import *
from .conv2d_alter_op import *
Expand Down
Loading

0 comments on commit 902a52b

Please sign in to comment.