File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ def __getitem__(self, idx: tuple) -> "MemRef":
108
108
if idx is None :
109
109
return expand_shape (self , (0 ,), loc = loc )
110
110
111
- idx = list ((idx ,) if isinstance (idx , int ) else idx )
111
+ idx = list ((idx ,) if isinstance (idx , ( int , slice ) ) else idx )
112
112
for i , d in enumerate (idx ):
113
113
if isinstance (d , int ):
114
114
idx [i ] = constant (d , index = True , loc = loc )
@@ -291,6 +291,9 @@ def global_(
291
291
sym_name = _get_sym_name (
292
292
previous_frame , check_func_call = "memref\\ .global_|global_"
293
293
)
294
+ assert (
295
+ sym_name is not None
296
+ ), "couldn't automatically find sym_name in previous frame"
294
297
if loc is None :
295
298
loc = get_user_code_loc ()
296
299
if initial_value is None :
Original file line number Diff line number Diff line change @@ -56,6 +56,24 @@ def test_simple_literal_indexing(ctx: MLIRContext):
56
56
filecheck (correct , ctx .module )
57
57
58
58
59
+ def test_simple_slicing (ctx : MLIRContext ):
60
+ mem = alloc (10 , T .i32 ())
61
+
62
+ w = mem [5 :]
63
+ w = mem [:5 ]
64
+
65
+ correct = dedent (
66
+ """\
67
+ module {
68
+ %alloc = memref.alloc() : memref<10xi32>
69
+ %subview = memref.subview %alloc[5] [5] [1] : memref<10xi32> to memref<5xi32, strided<[1], offset: 5>>
70
+ %subview_0 = memref.subview %alloc[0] [5] [1] : memref<10xi32> to memref<5xi32>
71
+ }
72
+ """
73
+ )
74
+ filecheck (correct , ctx .module )
75
+
76
+
59
77
def test_simple_literal_indexing_alloca (ctx : MLIRContext ):
60
78
@alloca_scope ([])
61
79
def demo_scope2 ():
You can’t perform that action at this time.
0 commit comments