Skip to content

Commit

Permalink
[TOPI] Added support for Mali Bifrost target
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaret committed Oct 2, 2019
1 parent 85a1d3f commit 708f513
Show file tree
Hide file tree
Showing 9 changed files with 1,286 additions and 9 deletions.
13 changes: 13 additions & 0 deletions python/tvm/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,19 @@ def vta(model='unknown', options=None):
return ret


def bifrost(model='unknown', options=None):
"""Return an ARM Mali GPU target (Bifrost architecture).
Parameters
----------
options : str or list of str
Additional options
"""
opts = ["-device=bifrost", '-model=%s' % model]
opts = _merge_opts(opts, options)
return _api_internal._TargetCreate("opencl", *opts)


def create(target_str):
"""Get a target given target string.
Expand Down
1 change: 1 addition & 0 deletions topi/python/topi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from . import cuda
from . import arm_cpu
from . import mali
from . import bifrost
from . import intel_graphics
from . import opengl
from . import util
Expand Down
28 changes: 19 additions & 9 deletions topi/python/topi/arm_cpu/conv2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,28 +552,38 @@ def _alter_conv2d_layout_arm(attrs, inputs, tinfos, F):
if "-device=arm_cpu" in target.options:
tile_size = 4
VC = cfg['tile_k'].size[-1]
elif "-device=bifrost" in target.options:
tile_size = 2
VC = 0
else:
from ..mali.conv2d import _pick_tile_size
tile_size = _pick_tile_size(tinfos[0], tinfos[1])
VC = cfg['tile_bna'].val

weight = F.nn.contrib_conv2d_winograd_weight_transform(copy_inputs[1],
tile_size=tile_size)
weight = F.reshape(weight,
newshape=(KH + tile_size - 1,
KW + tile_size - 1,
idxd(CO, VC), VC, CI))
weight = F.transpose(weight, axes=[0, 1, 2, 4, 3])
if VC > 0:
weight = F.reshape(weight,
newshape=(KH + tile_size - 1,
KW + tile_size - 1,
idxd(CO, VC), VC, CI))
weight = F.transpose(weight, axes=[0, 1, 2, 4, 3])
new_weight = tvm.placeholder((KH + tile_size - 1,
KH + tile_size -1,
idxd(CO, VC), CI, VC),
kernel.dtype)
else:
weight = F.reshape(weight,
newshape=(KH + tile_size - 1, KW + tile_size - 1, CO, CI))
new_weight = tvm.placeholder(
(KH + tile_size - 1, KH + tile_size -1, CO, CI), kernel.dtype
)

copy_inputs[1] = weight
new_attrs['tile_size'] = tile_size

# Store the same config for the altered operator (workload)
new_data = data
new_weight = tvm.placeholder((KH + tile_size - 1,
KH + tile_size -1,
idxd(CO, VC), CI, VC),
kernel.dtype)
new_workload = autotvm.task.args_to_workload(
[new_data, new_weight, strides, padding, dilation,
new_attrs[data_layout_key], out_dtype, tile_size],
Expand Down
8 changes: 8 additions & 0 deletions topi/python/topi/bifrost/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# pylint: disable=redefined-builtin, wildcard-import
"""ARM Mali GPU specific declaration and schedules."""
from __future__ import absolute_import as _abs

from .gemm import *
from .conv2d import *
from .dense import *
from .depthwise_conv2d import *
Loading

0 comments on commit 708f513

Please sign in to comment.