Skip to content

Commit 6ad83fe

Browse files
committed
lint
1 parent 4f1d75f commit 6ad83fe

33 files changed

+94
-53
lines changed

topi/python/topi/arm_cpu/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
17+
# pylint: disable=wildcard-import
1818
"""Schedule for ARM CPU"""
1919

2020
from .conv2d import *

topi/python/topi/arm_cpu/bitserial_conv2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from tvm import relay
2323
from .. import tag
2424
from ..nn.pad import pad
25-
from ..nn.bitserial_conv2d import bitserial_conv2d_nhwc, bitserial_conv2d_legalize
25+
from ..nn.bitserial_conv2d import bitserial_conv2d_legalize
2626
from ..nn.bitserial_util import bitpack, binary_op_multiplier
2727
from ..nn.util import get_pad_tuple
2828
from ..util import get_const_int, get_const_tuple

topi/python/topi/arm_cpu/conv2d.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@
3434

3535
@autotvm.register_topi_compute("conv2d_nchw_spatial_pack.arm_cpu")
3636
def conv2d_nchw_spatial_pack(cfg, data, kernel, strides, padding, dilation, out_dtype):
37+
"""Compute conv2d with NCHW layout"""
3738
return conv2d_spatial_pack_nchw(cfg, data, kernel, strides, padding,
3839
dilation, out_dtype, num_tile=2)
3940

4041

4142
@autotvm.register_topi_schedule("conv2d_nchw_spatial_pack.arm_cpu")
4243
def schedule_conv2d_nchw_spatial_pack(cfg, outs):
44+
"""Create schedule for conv2d_nchw"""
4345
s = tvm.create_schedule([x.op for x in outs])
4446

4547
def _callback(op):
@@ -69,12 +71,14 @@ def _callback(op):
6971

7072
@autotvm.register_topi_compute("conv2d_nhwc_spatial_pack.arm_cpu")
7173
def conv2d_nhwc_spatial_pack(cfg, data, kernel, strides, padding, dilation, out_dtype):
74+
"""Compute conv2d with NHWC layout"""
7275
return conv2d_spatial_pack_nhwc(cfg, data, kernel, strides, padding,
7376
dilation, out_dtype)
7477

7578

7679
@autotvm.register_topi_schedule("conv2d_nhwc_spatial_pack.arm_cpu")
7780
def schedule_conv2d_nhwc_spatial_pack(cfg, outs):
81+
"""Create schedule for conv2d_nhwc"""
7882
s = tvm.create_schedule([x.op for x in outs])
7983

8084
def _callback(op):
@@ -87,13 +91,15 @@ def _callback(op):
8791

8892
@autotvm.register_topi_compute("conv2d_nchw_winograd.arm_cpu")
8993
def conv2d_nchw_winograd(cfg, data, kernel, strides, padding, dilation, out_dtype):
94+
"""Compute conv2d_nchw layout using Winograd with weight transform"""
9095
tile_size = 4
9196
return _decl_winograd(cfg, data, kernel, strides, padding, dilation,
9297
out_dtype, tile_size)
9398

9499

95100
@autotvm.register_topi_schedule("conv2d_nchw_winograd.arm_cpu")
96101
def schedule_conv2d_nchw_winograd(cfg, outs):
102+
"""Create schedule for conv2d_nchw_winograd"""
97103
s = tvm.create_schedule([x.op for x in outs])
98104

99105
def _callback(op):
@@ -286,6 +292,7 @@ def _schedule_winograd(cfg, s, output, last):
286292

287293
@autotvm.register_topi_compute("conv2d_nchw_winograd_nnpack.arm_cpu")
288294
def conv2d_nchw_winograd_nnpack(cfg, data, kernel, strides, padding, dilation, out_dtype):
295+
"""Compute conv2d_nchw using nnpack Winograd implementation"""
289296
dtype = data.dtype
290297
if dtype == "float32":
291298
return _conv2d_arm_cpu_winograd_nnpack(
@@ -302,6 +309,7 @@ def conv2d_nchw_winograd_nnpack(cfg, data, kernel, strides, padding, dilation, o
302309

303310
@autotvm.register_topi_schedule("conv2d_nchw_winograd_nnpack.arm_cpu")
304311
def schedule_conv2d_nchw_winograd_nnpack(cfg, outs):
312+
"""Create schedule for conv2d_nchw_winograd_nnpack"""
305313
s = tvm.create_schedule([x.op for x in outs])
306314

307315
def _callback(op):
@@ -371,6 +379,7 @@ def _schedule_winograd_nnpack(cfg, s, output, last):
371379
@autotvm.register_topi_compute("conv2d_nchw_winograd_nnpack_without_weight_transform.arm_cpu")
372380
def conv2d_nchw_winograd_nnpack_without_weight_transform(
373381
cfg, data, transformed_kernel, bias, strides, padding, dilation, out_dtype):
382+
"""Compute conv2d_nchw using NNPack winograd without weight transform"""
374383
N, CI, IH, IW = get_const_tuple(data.shape)
375384
if isinstance(dilation, int):
376385
dilation_h = dilation_w = dilation

topi/python/topi/arm_cpu/conv2d_alter_op.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
# pylint: disable=invalid-name,unused-variable,unused-argument,no-member
17+
# pylint: disable=invalid-name,unused-variable,unused-argument,no-member,no-else-return
1818
"""Conv2D alter op and legalize functions for arm cpu"""
1919

2020
import logging
@@ -104,8 +104,8 @@ def _alter_conv2d_layout(attrs, inputs, tinfos, out_type):
104104
weight_expr, tile_size=tile_size)
105105
weight_expr = relay.reshape(weight_expr,
106106
newshape=(KH + tile_size - 1,
107-
KW + tile_size - 1,
108-
idxd(CO, VC), VC, CI))
107+
KW + tile_size - 1,
108+
idxd(CO, VC), VC, CI))
109109
weight_expr = relay.transpose(weight_expr, axes=[0, 1, 2, 4, 3])
110110

111111
new_attrs['tile_size'] = tile_size

topi/python/topi/arm_cpu/conv2d_int8.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import tvm
2121
from tvm import autotvm
22-
from .. import generic, tag
22+
from .. import tag
2323
from ..util import get_const_tuple
2424
from ..generic import conv2d as conv2d_generic
2525
from .. import nn
@@ -44,6 +44,7 @@ def _get_default_config(cfg, data, kernel, strides, padding, out_dtype):
4444
@autotvm.register_topi_compute("conv2d_NCHWc_int8.arm_cpu")
4545
def conv2d_NCHWc_int8(cfg, data, kernel, strides,
4646
padding, dilation, layout, out_layout, out_dtype):
47+
"""Compute conv2d int8 with NCHWc layout"""
4748
# layout and out_layout are not used here,
4849
# we keep them for debug convenience when dumping autotvm workload
4950
n, ic_chunk, ih, iw, ic_bn = get_const_tuple(data.shape)

topi/python/topi/arm_cpu/depthwise_conv2d.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727

2828
@autotvm.register_topi_compute("depthwise_conv2d_nchw.arm_cpu")
29-
def depthwise_conv2d_nchw(cfg, data, kernel, strides, padding, dilation, out_dtype):
29+
def depthwise_conv2d_nchw(_, data, kernel, strides, padding, dilation, out_dtype):
30+
"""Compute depthwise_conv2d with NCHW layout"""
3031
return nn.depthwise_conv2d_nchw(data, kernel, strides, padding, dilation, out_dtype)
3132

3233

@@ -177,6 +178,7 @@ def depthwise_conv2d_nchw_spatial_pack(cfg, data, kernel, strides, padding, dila
177178

178179
@autotvm.register_topi_schedule("depthwise_conv2d_nchw_spatial_pack.arm_cpu")
179180
def schedule_depthwise_conv2d_nchw_spatial_pack(cfg, outs):
181+
"""Create the schedule for depthwise_conv2d_nchw_spatial_pack"""
180182
outs = [outs] if isinstance(outs, tvm.tensor.Tensor) else outs
181183
s = tvm.create_schedule([x.op for x in outs])
182184

topi/python/topi/bifrost/conv2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
# pylint: disable=invalid-name,unused-variable,unused-argument
18+
# pylint: disable=invalid-name,unused-variable,unused-argument,no-else-return
1919
"""conv2d schedule on ARM Mali (Bifrost) GPU"""
2020

2121
import tvm

topi/python/topi/bifrost/dense.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def _callback(op):
5555
vec_size = [1, 2, 4, 8, 16]
5656
max_unroll = 32
5757

58-
dense = op.output(0)
58+
dense_out = op.output(0)
5959
output = outs[0]
6060

6161
y, x = s[output].op.axis
62-
c = s[dense].op.reduce_axis[0]
62+
c = s[dense_out].op.reduce_axis[0]
6363

6464
##### space definition begin #####
6565
cfg.define_split('tile_y', y, num_outputs=3)
@@ -73,8 +73,8 @@ def _callback(op):
7373
cfg.fallback_with_reference_log(ref_log)
7474
##### space definition end #####
7575

76-
if dense.op in s.outputs:
77-
dense = s.cache_write(output, 'local')
76+
if dense_out.op in s.outputs:
77+
dense_out = s.cache_write(output, 'local')
7878

7979
by, ty, yi = cfg['tile_y'].apply(s, output, y)
8080
bx, tx, xi = cfg['tile_x'].apply(s, output, x)
@@ -88,17 +88,17 @@ def _callback(op):
8888
s[output].unroll(yi)
8989
if cfg['tile_x'].size[-1] in vec_size:
9090
s[output].vectorize(xi)
91-
s[dense].compute_at(s[output], tx)
91+
s[dense_out].compute_at(s[output], tx)
9292

93-
k = s[dense].op.reduce_axis[0]
94-
y, x = s[dense].op.axis
95-
k, k_unroll = cfg['c_unroll'].apply(s, dense, k)
96-
s[dense].reorder(k, k_unroll, y, x)
97-
s[dense].unroll(k_unroll)
93+
k = s[dense_out].op.reduce_axis[0]
94+
y, x = s[dense_out].op.axis
95+
k, k_unroll = cfg['c_unroll'].apply(s, dense_out, k)
96+
s[dense_out].reorder(k, k_unroll, y, x)
97+
s[dense_out].unroll(k_unroll)
9898
if cfg['tile_y'].size[-1] < max_unroll:
99-
s[dense].unroll(y)
99+
s[dense_out].unroll(y)
100100
if cfg['tile_x'].size[-1] in vec_size:
101-
s[dense].vectorize(x)
101+
s[dense_out].vectorize(x)
102102

103103
traverse_inline(s, outs[0].op, _callback)
104104
return s

topi/python/topi/cuda/conv2d.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
# pylint: disable=invalid-name
17+
# pylint: disable=invalid-name, unused-argument
1818
"""Compute definition for conv2d with cuda backend"""
1919
import tvm
2020
from tvm import autotvm
@@ -28,11 +28,13 @@
2828

2929
@autotvm.register_topi_compute("conv2d_nchw.cuda")
3030
def conv2d_nchw(cfg, data, kernel, strides, padding, dilation, out_dtype='float32'):
31+
"""Compute conv2d with NCHW layout"""
3132
return nn.conv2d_nchw(data, kernel, strides, padding, dilation, out_dtype)
3233

3334

3435
@autotvm.register_topi_schedule("conv2d_nchw.cuda")
3536
def schedule_conv2d_nchw(cfg, outs):
37+
"""Create the schedule for conv2d_nchw"""
3638
outs = [outs] if isinstance(outs, tvm.tensor.Tensor) else outs
3739
s = tvm.create_schedule([x.op for x in outs])
3840

@@ -67,6 +69,7 @@ def _callback(op):
6769
@autotvm.register_topi_compute("conv2d_cudnn.cuda")
6870
def conv2d_cudnn(cfg, data, kernel, strides, padding, dilation, layout='NCHW',
6971
out_dtype='float32'):
72+
"""Compute conv2d using CuDNN library"""
7073
if layout == 'NCHW':
7174
tensor_format = 0 # CUDNN_TENSOR_NCHW
7275
N, _, H, W = get_const_tuple(data.shape)
@@ -110,4 +113,5 @@ def conv2d_cudnn(cfg, data, kernel, strides, padding, dilation, layout='NCHW',
110113

111114
@autotvm.register_topi_schedule("conv2d_cudnn.cuda")
112115
def schedule_conv2d_cudnn(cfg, outs):
116+
"""Create the schedule for conv2d_cudnn"""
113117
return generic.schedule_extern(outs)

topi/python/topi/cuda/conv2d_hwcn.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
# pylint: disable=invalid-name, too-many-locals, too-many-statements
17+
# pylint: disable=invalid-name, too-many-locals, too-many-statements, unused-argument
1818
"""Schedule for conv2d_hwcn with auto fusion"""
1919
import tvm
2020
from tvm import autotvm
21+
2122
from tvm.autotvm.task.space import SplitEntity
2223

2324
from .. import nn, tag
2425

2526
@autotvm.register_topi_compute("conv2d_hwcn.cuda")
2627
def conv2d_hwcn(cfg, data, kernel, strides, padding, dilation, out_dtype='float32'):
28+
"""Compute conv2d with HWCN layout on CUDA"""
2729
return nn.conv2d_hwcn(data, kernel, strides, padding, dilation, out_dtype)
2830

2931

0 commit comments

Comments
 (0)