Skip to content

Commit b2e9546

Browse files
author
Siyuan Feng
committed
fix error report on Store
1 parent fa3b34c commit b2e9546

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

python/tvm/script/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def transform_SubscriptAssign(self, node):
536536
if len(indexes) != 1:
537537
self.report_error(
538538
f"Store is only allowed with one index, but {len(indexes)} were provided.",
539-
tvm.ir.Span.union([x.span for x in indexes]),
539+
node.params[1].span,
540540
)
541541
# Store
542542
return tvm.tir.Store(

tests/python/unittest/test_tvmscript_error_report.py

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
18+
import pytest
19+
import sys
1720
import tvm
1821
from tvm import tir
1922
from tvm.script import ty, from_source
@@ -380,6 +383,17 @@ def test_match_buffer_shape_mismatch():
380383
check_error(buffer_shape_mismatch, 7)
381384

382385

386+
def high_dim_store() -> None:
387+
with tir.block([], "root"):
388+
B = tir.allocate([256], "float32", "global")
389+
for i, j in tir.grid(16, 16):
390+
B[i, j] = 1.0 # error: Store is only allowed with one index
391+
392+
393+
def test_high_dim_store():
394+
check_error(high_dim_store, 5)
395+
396+
383397
def check_error(module, rel_lineno):
384398
# Override the default renderer to accumulate errors
385399
_, start_line = inspect.getsourcelines(module)
@@ -404,31 +418,4 @@ def render(e):
404418

405419

406420
if __name__ == "__main__":
407-
test_buffer_bind()
408-
test_range_missing_args()
409-
test_undefined_buffer()
410-
test_unsupported_stmt()
411-
test_unsupported_function_call()
412-
test_missing_type_annotation()
413-
test_invalid_expr_stmt()
414-
test_invalid_for_function()
415-
test_invalid_block_function()
416-
test_return_not_allowed()
417-
test_tir_assert()
418-
test_no_body()
419-
test_allocate_with_buffers()
420-
test_inconsistent_binding()
421-
test_invalid_block_axes()
422-
test_miss_block_bind()
423-
test_invalid_loop_var()
424-
test_inconsistent_grid()
425-
test_invalid_match_buffer_region()
426-
test_duplicate_buffer()
427-
test_duplicate_block_signature()
428-
test_opaque_access_during_complete()
429-
test_convert_slice_to_bufferload()
430-
test_error_index_type()
431-
test_error_index_with_stop_slice()
432-
test_mismatch_args()
433-
test_tvm_exception_catch()
434-
test_match_buffer_shape_mismatch()
421+
sys.exit(pytest.main([__file__] + sys.argv[1:]))

0 commit comments

Comments
 (0)