Skip to content

Commit a8e6ee9

Browse files
ziyu-guokevinthesun
authored andcommitted
fix inconsistent tag name (#4134)
1 parent 5b1ca85 commit a8e6ee9

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

tests/python/relay/test_op_level2.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from tvm import relay
2323
from tvm.relay import transform
2424
from tvm.relay.testing import ctx_list
25+
from tvm.contrib import util
2526
import topi.testing
2627

2728
def run_infer_type(expr):
@@ -134,6 +135,46 @@ def run_test_conv2d(dtype, out_dtype, scale, dshape, kshape,
134135
op_res1 = intrp1.evaluate(func)(data, kernel)
135136
tvm.testing.assert_allclose(op_res1.asnumpy(), ref_res, rtol=1e-5, atol=1e-5)
136137

138+
def compile_test_conv2d_arm_cpu(dtype, out_dtype, scale, dshape, kshape,
139+
padding=(1, 1),
140+
groups=1,
141+
dilation=(1, 1),
142+
**attrs):
143+
x = relay.var("x", shape=dshape, dtype=dtype)
144+
w = relay.var("w", dtype=dtype)
145+
y = relay.nn.conv2d(x, w,
146+
padding=padding,
147+
dilation=dilation,
148+
groups=groups,
149+
**attrs)
150+
func = relay.Function([x, w], y)
151+
mod = tvm.relay.Module()
152+
mod["main"] = func
153+
154+
test_schedule='{"i": ["llvm -device=arm_cpu", "topi_nn_depthwise_conv2d_nchw", \
155+
[["TENSOR", [1, 512, 32, 32], "float32"], \
156+
["TENSOR", [512, 1, 3, 3], "float32"], \
157+
[1, 1], [1, 1], [1, 1], "float32"], {}, \
158+
["depthwise_conv2d_nchw", [1, 512, 32, 32, "float32"], \
159+
[512, 1, 3, 3, "float32"], [1, 1], [1, 1], [1, 1], "float32"], \
160+
{"i": 743640, "t": "contrib_spatial_pack", "c": null, \
161+
"e": [["tile_co", "sp", [512, 1]], ["tile_oh", "sp", [8, 1]], \
162+
["tile_ow", "sp", [1, 8]], \
163+
["reorder_0", "re", [0, 1, 2, 3, 4, 5, 8, 6, 7]], \
164+
["reorder_1", "re", [0, 1, 2, 3, 6, 4, 5]], \
165+
["ann_reduce", "an", ["unroll", "none"]], \
166+
["ann_spatial", "an", ["unroll", "unroll", "vec"]], \
167+
["data_pad_inline", "ot", 4], ["data_vec_inline", "ot", 1], \
168+
["conv_inline", "ot", 0]]}], "r": [[0.0002933163], \
169+
0, 3.1976189613342285, 1570811630.6058347], "v": 0.1}'
170+
temp = util.tempdir()
171+
with open(temp.relpath("temp.log"), "w") as log_file:
172+
log_file.write(test_schedule)
173+
with autotvm.apply_history_best(temp.relpath("temp.log")):
174+
with relay.build_config(opt_level=3):
175+
print('Compiling...')
176+
graph_json, mod, params = tvm.relay.build(mod, target="llvm -device=arm_cpu")
177+
137178
# depthwise conv2d
138179
dshape = (1, 32, 18, 18)
139180
kshape = (32, 1, 3, 3)
@@ -142,6 +183,13 @@ def run_test_conv2d(dtype, out_dtype, scale, dshape, kshape,
142183
fref=lambda x, w: topi.testing.depthwise_conv2d_python_nchw(
143184
x, w, (1, 1), "SAME"))
144185

186+
# depthwise conv2d for arm_cpu
187+
dshape = (1, 512, 32, 32)
188+
kshape = (512, 1, 3, 3)
189+
compile_test_conv2d_arm_cpu("float32", "float32", 1, dshape, kshape,
190+
padding=(1, 1), channels=512,
191+
groups=512, kernel_size=(3 ,3))
192+
145193
# CUDA is disabled for 'direct' schedule:
146194
# https://github.com/apache/incubator-tvm/pull/3070#issuecomment-486597553
147195
# group conv2d

topi/python/topi/arm_cpu/depthwise_conv2d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def _callback(op):
134134
data = data_pad.op.input_tensors[0]
135135
_schedule(cfg, s, data, data_pad, kernel, output)
136136

137-
if op.tag == 'spatial_depthwise_conv_nchw_output':
137+
if op.tag == 'spatial_depthwise_conv2d_nchw_output':
138138
output = op.output(0)
139139
conv = op.input_tensors[0]
140140
data_vec = conv.op.input_tensors[0]
@@ -316,7 +316,7 @@ def _decl_spatial_pack(cfg, data, kernel, strides, padding, dilation, out_dtype,
316316
conv[n,
317317
idxdiv(co, VC), idxdiv(h, VH), idxdiv(w, VW),
318318
idxmod(h, VH), idxmod(w, VW), idxmod(co, VC)],
319-
name='output_unpack', tag='spatial_depthwise_conv_nchw_output')
319+
name='output_unpack', tag='spatial_depthwise_conv2d_nchw_output')
320320
return output
321321

322322
def _schedule_spatial_pack(cfg, s, data_vec, kernel_vec,

0 commit comments

Comments
 (0)