-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathtest_tvmscript_error_report.py
More file actions
666 lines (509 loc) · 21.7 KB
/
Copy pathtest_tvmscript_error_report.py
File metadata and controls
666 lines (509 loc) · 21.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# 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.
# ruff: noqa: E741, F401, F821, F841, RUF005
import inspect
import re
import pytest
import tvm
import tvm.testing
from tvm import tirx
from tvm.script import from_source
from tvm.script import tirx as T
def check_error(func, rel_lineno):
"""check if TIR script throws error"""
check_error_re = re.compile(r"^.*# check_error: (.+)$")
source_code = inspect.getsource(func)
indent = len(re.match(r"^\s*", source_code).group(0))
source_code = "@T.prim_func(s_tir=True)\n" + "\n".join(
line[indent:] for line in source_code.splitlines()
)
# Parse errors now raise DiagnosticError with formatted source location.
with pytest.raises(tvm.error.DiagnosticError) as execinfo:
from_source(source_code)
err_str = str(execinfo.value)
if rel_lineno is None:
return
# The error message contains " --> <source>:<lineno>:<col>" formatted by Diagnostics.error().
# Accept either rel_lineno or rel_lineno+1 to match old tolerance.
assert f":{rel_lineno}:" in err_str or f":{rel_lineno + 1}:" in err_str, (
f"Expected error message to contain line {rel_lineno}, got:\n{err_str}"
)
error_line = source_code.split("\n")[rel_lineno]
m = check_error_re.match(error_line)
if m:
expected_error_text = m.group(1)
assert expected_error_text in err_str, (
f'check_error expects "{expected_error_text}" in error: {err_str}'
)
def test_buffer_bind():
def buffer_bind_missing_args(a: T.handle) -> None:
A = T.match_buffer((16, 16), "float32") # error
check_error(buffer_bind_missing_args, 2)
def test_undefined_buffer():
def undefined_buffer(a: T.handle) -> None:
A = T.match_buffer(a, (16, 16), "float32")
for i in T.serial(16):
for j in T.serial(0, 16):
C[i, j] = 0.0 # error
check_error(undefined_buffer, 6)
def test_unsupported_function_call():
def unsupported_function_call(a: T.handle) -> None:
A = T.match_buffer(a, (16, 16), "float32")
for i in T.const_range(16): # error
for j in T.serial(0, 16):
A[i, j] = 0.0
check_error(unsupported_function_call, 4)
def test_missing_type_annotation():
def missing_type_annotation(a) -> None: # error
T.evaluate(0.0)
check_error(missing_type_annotation, 1)
def test_invalid_for_function():
def invalid_for_function(a: T.handle) -> None:
A = T.match_buffer(a, (16, 16), "float32")
for i in T.evaluate(0.0): # error
for j in T.serial(0, 16):
A[i, j] = 0.0
check_error(invalid_for_function, 4)
def test_invalid_block_function():
def invalid_block_function(a: T.handle) -> None:
A = T.match_buffer(a, (16, 16), "float32")
with T.evaluate(0.0): # error
T.evaluate(1.0)
check_error(invalid_block_function, 4)
def test_return_not_allowed():
def return_not_allowed(a: T.handle) -> None:
return T.evaluate(0) # error
check_error(return_not_allowed, 2)
def test_no_body():
def no_body(a: T.handle) -> None:
A = T.match_buffer(a, (16, 16), "float32")
T.realize(A, "") # error
check_error(no_body, 3)
def test_inconsistent_binding():
def inconsistent_binding_value() -> None:
for i, j in T.grid(16, 16):
vi, vj = T.axis.remap("SS", [i]) # error
T.evaluate(1.0)
def inconsistent_binding_type() -> None:
for i, j in T.grid(16, 16):
vi, vj = T.axis.remap("S", [i, j]) # error
T.evaluate(1.0)
check_error(inconsistent_binding_value, 3)
check_error(inconsistent_binding_type, 3)
def test_error_remap_args():
def error_remap_type() -> None:
for i, j in T.grid(16, 16):
with T.sblock():
vi, vj = T.axis.remap("TT", [i, j]) # error
T.evaluate(1.0)
def error_remap_value() -> None:
for i, j in T.grid(16, 16):
with T.sblock():
vi, vj = T.axis.remap("SS", [i + j, j]) # error
T.evaluate(1.0)
check_error(error_remap_type, 4)
check_error(error_remap_value, 4)
def test_invalid_block_axes():
def invalid_block_axes(a: T.handle) -> None:
A = T.match_buffer(a, (16, 16), "float32")
for i, j in T.grid(16, 16):
with T.sblock():
vi = T.axis.S(i, A) # error
T.evaluate(1.0)
check_error(invalid_block_axes, 5)
def test_duplicate_block_axes():
def duplicate_block_axes() -> None:
for i, j in T.grid(16, 16):
with T.sblock():
vi = T.axis.S(16, i)
vi = T.axis.S(16, j) # error
T.evaluate(1.0)
def duplicate_block_axes_remap() -> None:
for i, j in T.grid(16, 16):
with T.sblock():
vi, vi = T.axis.remap("SS", [i, j]) # error
T.evaluate(1.0)
check_error(duplicate_block_axes, 5)
check_error(duplicate_block_axes_remap, 4)
def test_miss_block_bind():
def miss_block_bind_value() -> None:
for i, j in T.grid(128, 128):
with T.sblock():
vi = T.axis.S(i) # error
T.evaluate(1.0)
check_error(miss_block_bind_value, 4)
def test_invalid_loop_var():
def invalid_loop_var() -> None:
for i, j in range(0, 16): # error
T.evaluate(1.0)
check_error(invalid_loop_var, 2)
def test_inconsistent_grid():
def inconsistent_grid(A: T.Buffer(16)) -> None:
for i in T.grid(16, 16): # valid, i is a tuple (iter0, iter1)
T.evaluate(A[i]) # error
check_error(inconsistent_grid, 3)
def test_invalid_match_buffer_region():
def invalid_match_buffer_region() -> None:
for i, j in T.grid(128, 128):
with T.sblock():
vi, vj = T.axis.remap("SS", [i, j])
A = T.match_buffer(vi) # error
T.evaluate(1.0)
check_error(invalid_match_buffer_region, 5)
def test_duplicate_buffer():
def duplicate_buffer() -> None:
A = T.sblock_alloc_buffer((128, 128), "float32")
A = T.sblock_alloc_buffer((128, 128), "float32") # error
check_error(duplicate_buffer, 3)
def test_duplicate_block_signature():
def duplicate_reads() -> None:
A = T.sblock_alloc_buffer((128, 128), "float32")
for i, j in T.grid(128, 128):
with T.sblock():
vi, vj = T.axis.remap("SS", [i, j])
T.reads(A[0:8, 0:8])
T.reads(A[0:16, 0:16]) # error
T.evaluate(1.0)
def duplicate_writes() -> None:
A = T.sblock_alloc_buffer((128, 128), "float32")
for i, j in T.grid(128, 128):
with T.sblock():
vi, vj = T.axis.remap("SS", [i, j])
T.writes(A[0:8, 0:8])
T.writes(A[0:16, 0:16]) # error
T.evaluate(1.0)
def duplicate_predicate() -> None:
for i, j in T.grid(16, 16):
with T.sblock():
vi, vj = T.axis.remap("SS", [i, j])
T.where(1)
T.where(0) # error
def duplicate_init() -> None:
for i, j in T.grid(16, 16):
with T.sblock():
vi, vj = T.axis.remap("SS", [i, j])
with T.init():
T.evaluate(1.0)
with T.init(): # error
T.evaluate(1.0)
def duplicate_axes() -> None:
for i, j in T.grid(16, 16):
with T.sblock():
vi, vj = T.axis.remap("SS", [i, j])
vi = T.axis.S(i, 16) # error
T.evaluate(1.0)
def duplicate_sblock_attrs_with_same_key_diff_value() -> None:
for i, j in T.grid(16, 16):
with T.sblock():
vi, vj = T.axis.remap("SS", [i, j])
T.sblock_attr({"key1": "block1"})
T.sblock_attr({"key1": "block2"}) # error
T.evaluate(1.0)
check_error(duplicate_reads, 7)
check_error(duplicate_writes, 7)
check_error(duplicate_predicate, 6)
check_error(duplicate_init, 7)
check_error(duplicate_axes, 5)
check_error(duplicate_sblock_attrs_with_same_key_diff_value, 6)
def test_opaque_access_during_complete():
def opaque_access_during_complete(a: T.handle) -> None: # error
A = T.match_buffer(a, (16, 16), "float32")
for i, j in T.grid(16, 16):
with T.sblock():
T.evaluate(T.call_extern("dummy_extern_function", A.data, dtype="int32"))
check_error(opaque_access_during_complete, None)
def test_convert_slice_to_bufferload():
def convert_slice_to_bufferload() -> None:
A = T.sblock_alloc_buffer((128, 128), "float32")
for i, j in T.grid(128, 128):
with T.sblock():
vi, vj = T.axis.remap("SS", [i, j])
A[vi, vj] = A[vi : vi + 2, vj] + 1 # error
check_error(convert_slice_to_bufferload, 6)
def test_tvm_exception_catch_from_special_stmt():
def special_stmt_except() -> None:
A = T.sblock_alloc_buffer("(128, 128)", "float32") # error
T.evaluate(1.0)
check_error(special_stmt_except, 2)
def test_tvm_exception_catch_from_scope_handler():
def scope_handler_except() -> None:
for i in T.serial("1", "1"): # error
T.evaluate(1)
check_error(scope_handler_except, 2)
def test_tvm_exception_catch_from_bare_intrin():
def intrin_except_unassign(a: T.handle) -> None:
A = T.match_buffer(a, (16, 16), "float32")
T.evaluate(A) # error
check_error(intrin_except_unassign, 3)
def test_tvm_exception_catch_from_assigned_intrin():
def intrin_except_assign(a: T.handle) -> None:
A = T.match_buffer(a, (16, 16), "float32")
A[0, 0] = A[A] # error
check_error(intrin_except_assign, 3)
def test_match_buffer_shape_mismatch():
def buffer_shape_mismatch(a: T.handle) -> None:
A = T.match_buffer(a, (8, 8))
for i, j in T.grid(8, 2):
with T.sblock():
T.reads([])
T.writes([A[i, j * 4 : j * 4 + 4]])
sub_A = T.match_buffer(
A[i, j * 4 : j * 4 + 4], (5)
) # error: shape mismatched between 4 and 5
for jj in range(0, 4):
sub_A[i, j * 4 + jj] = 1
check_error(buffer_shape_mismatch, 7)
def test_high_dim_store():
def high_dim_store() -> None:
with T.sblock("root"):
B = T.alloc_buffer((256,), "float32")
for i, j in T.grid(16, 16):
B[i, j] = 1.0 # error: Store is only allowed with one index
check_error(high_dim_store, 5)
def test_block_has_option_vars():
def block_has_option_vars() -> None:
with T.sblock("root") as x: # error: block does not support option_vars
T.evaluate(0.0)
check_error(block_has_option_vars, 2)
def test_implicit_root_has_attrs():
def implicit_root_has_read():
T.reads([]) # error: implicit root does not support reads
T.evaluate(0.0)
def implicit_root_has_write():
T.writes([]) # error: implicit root does not support writes
T.evaluate(0.0)
def implicit_root_has_attrs():
T.sblock_attr({}) # error: implicit root does not support sblock_attr
T.evaluate(0.0)
def implicit_root_has_predicate():
T.where(True) # error: implicit root does not support predicate
T.evaluate(0.0)
def implicit_root_has_axes():
v = T.axis.S(0, 0) # error: implicit root does not support axis define
T.evaluate(0.0)
check_error(implicit_root_has_read, 2)
check_error(implicit_root_has_write, 2)
check_error(implicit_root_has_attrs, 2)
check_error(implicit_root_has_predicate, 2)
check_error(implicit_root_has_axes, 2)
@T.prim_func(s_tir=True)
def elementwise_not_affine(a: T.handle, b: T.handle) -> None:
A = T.match_buffer(a, (128, 128, 128, 128))
B = T.match_buffer(b, (128, 128, 128, 128))
for i, j, k, l in T.grid(128, 128, 128, 8):
with T.sblock("B"):
vi, vj, vk = T.axis.remap("SSS", [i, j, k])
vl = T.axis.S(128, l * 16)
B[vi, vj, vk, vl] = A[vi, vj, vk, vl] * 2.0
@T.prim_func(s_tir=True)
def elementwise_non_single_branch(a: T.handle, b: T.handle) -> None:
A = T.match_buffer(a, (128, 128, 128))
C = T.sblock_alloc_buffer((128, 128, 128))
B = T.match_buffer(b, (128, 128, 128))
for i, j in T.grid(128, 128):
for k in T.serial(0, 128):
with T.sblock("C"):
vi, vj, vk = T.axis.remap("SSS", [i, j, k])
C[vi, vj, vk] = A[vi, vj, vk] * 2.0
for k in T.serial(0, 128):
with T.sblock("B"):
vi, vj, vk = T.axis.remap("SSS", [i, j, k])
B[vi, vj, vk] = C[vi, vj, vk] * 2.0
def test_reorder_fail_block():
sch = tvm.s_tir.Schedule(elementwise_not_affine, debug_mask="all")
block_b = sch.get_sblock("B")
i, j, k, l = sch.get_loops(block_b)
with pytest.raises(tvm.s_tir.ScheduleError) as execinfo:
sch.reorder(l, i)
expected_sub_error_message = (
" # tirx.SBlock#0\n"
' with T.sblock("B"):\n'
" ^^^^^^^^^^^^^^^^^^^\n"
)
assert expected_sub_error_message in str(execinfo.value)
def test_reorder_fail_nested_loop_inner():
sch = tvm.s_tir.Schedule(elementwise_non_single_branch, debug_mask="all")
block_b = sch.get_sblock("B")
i, j, k = sch.get_loops(block_b)
with pytest.raises(tvm.s_tir.ScheduleError) as execinfo:
sch.reorder(k, i)
expected_sub_error_message = (
" for i in range(128):\n"
" # tirx.For#0\n"
" for j in range(128):\n"
" ^^^^^^^^^^^^^^^^^^^^\n"
)
assert expected_sub_error_message in str(execinfo.value)
def test_fuse_fail_nested_loop_outer():
sch = tvm.s_tir.Schedule(elementwise_non_single_branch, debug_mask="all")
block_b = sch.get_sblock("B")
i, j, k = sch.get_loops(block_b)
with pytest.raises(tvm.s_tir.ScheduleError) as execinfo:
sch.fuse(k, i)
expected_sub_error_message = (
" # tirx.For#1\n"
" for i in range(128):\n"
" ^^^^^^^^^^^^^^^^^^^^\n"
" for j in range(128):\n"
)
assert expected_sub_error_message in str(execinfo.value)
def test_report_error_root_block():
sch = tvm.s_tir.Schedule(elementwise_non_single_branch, debug_mask="all")
root = sch.get_sblock("root")
with pytest.raises(tvm.s_tir.ScheduleError) as execinfo:
sch.compute_inline(root)
expected_sub_error_message = (
' # tirx.SBlock#0\n with T.sblock("root"):\n ^^^^^^^^^^^^^^^^^^^^^^\n'
)
assert expected_sub_error_message in str(execinfo.value)
def test_load_var():
def load_var_multiple() -> None:
d = T.float32()
d[2] = d[2, 1] # error cannot provide two indices to load
check_error(load_var_multiple, 3)
def test_store_var():
def store_var_multiple() -> None:
d = T.float32()
d[2, 1] = d[1] # error cannot provide two indices to store
check_error(store_var_multiple, 3)
def test_load_handle():
def load_handle(h: T.handle) -> None:
h_ = T.match_buffer(h, [1])
h_[0] = h[0] # error cannot load from handle
check_error(load_handle, 3)
def test_store_handle():
def store_handle(h: T.handle) -> None:
h_ = T.match_buffer(h, [1])
h[0] = h_[0] # error cannot store to handle
check_error(store_handle, 3)
def test_binop_bad_ast_type():
def binop_bad_ast_type(h: T.handle):
h_ = T.match_buffer(h, [1])
h_[0] = h + [2] # error rhs should be a primexpr
check_error(binop_bad_ast_type, 3)
def test_binop_bad_type():
def binop_bad_type(h: T.handle):
h_ = T.match_buffer(h, [1])
h_[0] = h + 2 # error lhs and rhs should be the same type
check_error(binop_bad_type, 3)
def test_non_integer_typed_block_iter():
def non_integer_typed_block_iter():
with T.sblock():
i = T.axis.S(0.1, 0.1) # error IterVar requires an integer dtype
check_error(non_integer_typed_block_iter, 3)
def test_illegal_buffer_slice():
def strided_buffer_region(A: T.handle):
# do not allow stride in buffer region
A = T.match_buffer((128, 128), "int32")
with T.sblock():
T.reads([])
T.writes([A[0:128:2, 0:128:3]]) # error
T.evaluate(T.call_extern("strided_compute", dtype=""))
def access_reversed_slice(A: T.handle):
# do not allow reversed slice step
A = T.match_buffer((128,), "int32")
A[0:128:-1] = T.broadcast(1, 128) # error
def access_non_const_slice_length(A: T.handle):
# do not allow non-constant slice length
A = T.match_buffer((128,), "int32")
for i in range(4):
T.evaluate(A[0:i:1]) # error
check_error(strided_buffer_region, 3)
check_error(access_reversed_slice, 3)
check_error(access_non_const_slice_length, 3)
def test_syntax_sugar_fail():
def loop_syntax_sugar_fail(a: T.handle) -> None:
A = T.match_buffer(a, (128,))
for i in T.thread_binding(128, 128):
A[i] = A[i] * 2.0
check_error(loop_syntax_sugar_fail, 3)
def test_multi_line_error_report():
"""A parse error whose offending AST node spans several physical source
lines must render ALL spanned lines (each with its own gutter line number
and an underline covering the span), not just the first line."""
# The offending call (`T.axis.remap(...)`) is deliberately split across
# four physical lines so its AST node spans lineno..end_lineno > lineno.
source_code = "\n".join(
[
"@T.prim_func(s_tir=True)",
"def f() -> None:",
" for i, j in T.grid(16, 16):",
" vi, vj = T.axis.remap(",
' "S",',
" [i, j],",
" ) # error",
" T.evaluate(1.0)",
]
)
with pytest.raises(tvm.error.DiagnosticError) as execinfo:
from_source(source_code)
err_str = str(execinfo.value)
# All four spanned source lines must appear in the rendered snippet.
assert "T.axis.remap(" in err_str, err_str
assert '"S",' in err_str, err_str
assert "[i, j]," in err_str, err_str
# The trailing `)` closing line is also part of the span.
rendered_lines = err_str.splitlines()
assert any(" 7 " in line and ")" in line for line in rendered_lines), err_str
# The underline carets must be present on more than one line (multi-line).
marker_lines = [line for line in rendered_lines if "^" in line]
assert len(marker_lines) >= 2, err_str
# The gutter must show distinct line numbers for the spanned lines.
assert " 4 " in err_str and " 5 " in err_str and " 6 " in err_str, err_str
def test_format_source_snippet_multi_line():
"""Unit-level check that _format_source_snippet renders every line in a
multi-line span, with the underline covering start-col..EOL on the first
line, full interior lines, and col-1..end-col on the last line."""
from tvm.script.parser.core.diagnostics import _format_source_snippet
source_lines = [
"first ignored line\n",
" foo(bar,\n",
" baz,\n",
" qux)\n",
"last ignored line\n",
]
# Span lines 2..4 (1-based), starting at col 5 ('foo'), ending at col 13
# (exclusive) on line 4.
snippet = _format_source_snippet(
source_lines, lineno=2, col_offset=5, end_lineno=4, end_col_offset=13
)
lines = snippet.splitlines()
# All three spanned source lines must be present.
assert any("foo(bar," in line for line in lines), snippet
assert any("baz," in line for line in lines), snippet
assert any("qux)" in line for line in lines), snippet
# Underline carets present on the first line under 'foo(bar,'.
assert "^" in snippet, snippet
# The line numbers 2, 3, 4 appear in the gutter.
assert " 2 |" in snippet and " 3 |" in snippet and " 4 |" in snippet, snippet
def test_format_source_snippet_single_line_unchanged():
"""A single-line span (end_lineno == lineno) underlines only the
[col_offset, end_col_offset) columns on that one line."""
from tvm.script.parser.core.diagnostics import _format_source_snippet
source_lines = ["ignored\n", " abc + def\n", "ignored\n"]
# Underline just 'abc' (cols 5..8 exclusive) on line 2.
snippet = _format_source_snippet(
source_lines, lineno=2, col_offset=5, end_lineno=2, end_col_offset=8
)
lines = snippet.splitlines()
# Exactly one source-text line and one marker line (plus the leading gutter).
text_lines = [line for line in lines if "abc + def" in line]
assert len(text_lines) == 1, snippet
marker_line = next(line for line in lines if "^" in line)
assert marker_line.count("^") == 3, snippet
if __name__ == "__main__":
tvm.testing.main()