19
19
class CompiledModuleAPI (unittest .TestCase ):
20
20
def testTensorDim (self ):
21
21
class BasicModule (CompiledModule ):
22
- def foobar (self , a = AbstractTensor (None , 3 )):
22
+ def foobar (self , a : AbstractTensor (None , 3 )):
23
23
return IREE .tensor_dim (a , 0 )
24
24
25
25
inst = BasicModule (context = Context ())
@@ -31,7 +31,7 @@ def foobar(self, a=AbstractTensor(None, 3)):
31
31
32
32
def testTensorEmpty (self ):
33
33
class BasicModule (CompiledModule ):
34
- def foobar (self , x = AbstractIndex ):
34
+ def foobar (self , x : AbstractIndex ):
35
35
empty = IREE .tensor_empty (x , 16 )
36
36
dim0 = IREE .tensor_dim (empty , 0 )
37
37
return empty , dim0
@@ -46,7 +46,7 @@ def foobar(self, x=AbstractIndex):
46
46
47
47
def testTensorSplat (self ):
48
48
class BasicModule (CompiledModule ):
49
- def foobar (self , x = AbstractIndex , y = AbstractF32 ):
49
+ def foobar (self , x : AbstractIndex , y : AbstractF32 ):
50
50
empty = IREE .tensor_splat (x , 34 , value = y , dtype = torch .float32 )
51
51
dim0 = IREE .tensor_dim (empty , 0 )
52
52
return empty , dim0
@@ -63,7 +63,7 @@ def foobar(self, x=AbstractIndex, y=AbstractF32):
63
63
64
64
def testTensorTrace (self ):
65
65
class BasicModule (CompiledModule ):
66
- def foobar (self , x = AbstractTensor (None ), y = AbstractTensor (3 )):
66
+ def foobar (self , x : AbstractTensor (None ), y : AbstractTensor (3 )):
67
67
IREE .tensor_trace ("DEBUG" , x , y )
68
68
69
69
inst = BasicModule (context = Context ())
@@ -75,7 +75,7 @@ def testStoreDynamic(self):
75
75
class BasicModule (CompiledModule ):
76
76
x = export_global (AbstractTensor (None , 34 ), mutable = True )
77
77
78
- def foobar (self , x = AbstractIndex , y = AbstractF32 ):
78
+ def foobar (self , x : AbstractIndex , y : AbstractF32 ):
79
79
splat = IREE .tensor_splat (x , 34 , value = y , dtype = torch .float32 )
80
80
self .x = splat
81
81
@@ -91,7 +91,7 @@ def foobar(self, x=AbstractIndex, y=AbstractF32):
91
91
92
92
def testTensorSliceStatic (self ):
93
93
class BasicModule (CompiledModule ):
94
- def foobar (self , x = AbstractTensor (3 , 4 )):
94
+ def foobar (self , x : AbstractTensor (3 , 4 )):
95
95
return IREE .tensor_slice (x , 0 , (1 , 3 ))
96
96
97
97
inst = BasicModule (context = Context ())
@@ -104,7 +104,7 @@ def foobar(self, x=AbstractTensor(3, 4)):
104
104
105
105
def testTensorSliceDynamicIndex (self ):
106
106
class SliceDynamicIndex (CompiledModule ):
107
- def foobar (self , x = AbstractIndex ):
107
+ def foobar (self , x : AbstractIndex ):
108
108
empty = IREE .tensor_empty (x , 16 )
109
109
return IREE .tensor_slice (empty , x , 4 )
110
110
@@ -118,7 +118,7 @@ def foobar(self, x=AbstractIndex):
118
118
119
119
def testTensorSliceDynamicLength (self ):
120
120
class SliceDynamicIndex (CompiledModule ):
121
- def foobar (self , x = AbstractIndex , y = AbstractIndex ):
121
+ def foobar (self , x : AbstractIndex , y : AbstractIndex ):
122
122
empty = IREE .tensor_empty (x , 16 )
123
123
return IREE .tensor_slice (empty , (x , y ), 4 )
124
124
@@ -134,10 +134,10 @@ def testTensorUpdateStatic(self):
134
134
class UpdateStatic (CompiledModule ):
135
135
def foobar (
136
136
self ,
137
- target = AbstractTensor (4 , 4 ),
138
- update = AbstractTensor (2 , 2 ),
139
- i = AbstractIndex ,
140
- j = AbstractIndex ,
137
+ target : AbstractTensor (4 , 4 ),
138
+ update : AbstractTensor (2 , 2 ),
139
+ i : AbstractIndex ,
140
+ j : AbstractIndex ,
141
141
):
142
142
return IREE .tensor_update (target , update , i , j )
143
143
@@ -153,11 +153,11 @@ def testTensorUpdateDynamic(self):
153
153
class UpdateDynamic (CompiledModule ):
154
154
def foobar (
155
155
self ,
156
- x = AbstractIndex ,
157
- y = AbstractIndex ,
158
- i = AbstractIndex ,
159
- j = AbstractIndex ,
160
- value = AbstractF32 ,
156
+ x : AbstractIndex ,
157
+ y : AbstractIndex ,
158
+ i : AbstractIndex ,
159
+ j : AbstractIndex ,
160
+ value : AbstractF32 ,
161
161
):
162
162
target = IREE .tensor_empty (x , y )
163
163
update = IREE .tensor_splat (i , j , value = value , dtype = torch .float32 )
@@ -173,7 +173,7 @@ def foobar(
173
173
174
174
def testTensorReshape (self ):
175
175
class ReshapeModule (CompiledModule ):
176
- def foobar (self , x = AbstractIndex , y = AbstractIndex ):
176
+ def foobar (self , x : AbstractIndex , y : AbstractIndex ):
177
177
empty = IREE .tensor_empty (x , 16 )
178
178
reshaped = IREE .tensor_reshape (empty , 1 , y , y )
179
179
return reshaped
@@ -188,7 +188,7 @@ def foobar(self, x=AbstractIndex, y=AbstractIndex):
188
188
189
189
def testScalarAddInt (self ):
190
190
class ArithModule (CompiledModule ):
191
- def foobar (self , a = AbstractI32 , b = AbstractI32 ):
191
+ def foobar (self , a : AbstractI32 , b : AbstractI32 ):
192
192
return a + b
193
193
194
194
inst = ArithModule (context = Context ())
@@ -197,7 +197,7 @@ def foobar(self, a=AbstractI32, b=AbstractI32):
197
197
198
198
def testScalarAddFloat (self ):
199
199
class ArithModule (CompiledModule ):
200
- def foobar (self , a = AbstractF32 , b = AbstractF32 ):
200
+ def foobar (self , a : AbstractF32 , b : AbstractF32 ):
201
201
return a + b
202
202
203
203
inst = ArithModule (context = Context ())
@@ -206,7 +206,7 @@ def foobar(self, a=AbstractF32, b=AbstractF32):
206
206
207
207
def testScalarAddLiteral (self ):
208
208
class ArithModule (CompiledModule ):
209
- def foobar (self , a = AbstractI32 ):
209
+ def foobar (self , a : AbstractI32 ):
210
210
return a + 1
211
211
212
212
inst = ArithModule (context = Context ())
@@ -216,7 +216,7 @@ def foobar(self, a=AbstractI32):
216
216
217
217
def testScalarAddLiteralMixedType (self ):
218
218
class ArithModule (CompiledModule ):
219
- def foobar (self , a = AbstractI32 ):
219
+ def foobar (self , a : AbstractI32 ):
220
220
return a + 3.23
221
221
222
222
inst = ArithModule (context = Context ())
0 commit comments