1818import pytest
1919import numpy as np
2020from typing import *
21- import collections
2221
2322from tvm import te
2423import tvm .testing
2726from tvm .contrib .hexagon .session import Session
2827import tvm .topi .hexagon .slice_ops as sl
2928from ..infrastructure import allocate_hexagon_array , transform_numpy
30- from ..pytest_util import get_multitest_ids
29+ from ..pytest_util import (
30+ get_multitest_ids ,
31+ create_populated_numpy_ndarray ,
32+ TensorContentConstant ,
33+ TensorContentRandom ,
34+ TensorContentDtypeMin ,
35+ TensorContentDtypeMax ,
36+ )
3137
3238
3339input_layout = tvm .testing .parameter (
3642
3743
3844@tvm .testing .fixture
39- def input_np (input_shape , dtype ):
40- return np . random . random (input_shape ). astype ( dtype )
45+ def input_np (input_shape , dtype : str , input_tensor_populator ):
46+ return create_populated_numpy_ndarray (input_shape , dtype , input_tensor_populator )
4147
4248
4349@tvm .testing .fixture
@@ -61,6 +67,7 @@ class TestAvgPool2dSlice:
6167 "cnt_padded" , # count_include_pad
6268 "out_layout" , # output_layout
6369 None , # dtype
70+ None , # input_tensor_populator
6471 ]
6572
6673 _multitest_params = [
@@ -74,6 +81,7 @@ class TestAvgPool2dSlice:
7481 True ,
7582 "nhwc-8h2w32c2w-2d" ,
7683 "float16" ,
84+ TensorContentRandom (),
7785 ),
7886 (
7987 [1 , 16 , 16 , 32 ],
@@ -85,6 +93,7 @@ class TestAvgPool2dSlice:
8593 True ,
8694 "nhwc-8h2w32c2w-2d" ,
8795 "float16" ,
96+ TensorContentRandom (),
8897 ),
8998 (
9099 [1 , 8 , 8 , 32 ],
@@ -96,6 +105,7 @@ class TestAvgPool2dSlice:
96105 True ,
97106 "nhwc-8h2w32c2w-2d" ,
98107 "float16" ,
108+ TensorContentRandom (),
99109 ),
100110 # Test non-one stride and dilation
101111 (
@@ -108,6 +118,7 @@ class TestAvgPool2dSlice:
108118 True ,
109119 "nhwc-8h2w32c2w-2d" ,
110120 "float16" ,
121+ TensorContentRandom (),
111122 ),
112123 (
113124 [1 , 8 , 8 , 32 ],
@@ -119,6 +130,7 @@ class TestAvgPool2dSlice:
119130 True ,
120131 "nhwc-8h2w32c2w-2d" ,
121132 "float16" ,
133+ TensorContentRandom (),
122134 ),
123135 (
124136 [1 , 8 , 8 , 32 ],
@@ -130,6 +142,7 @@ class TestAvgPool2dSlice:
130142 True ,
131143 "nhwc-8h2w32c2w-2d" ,
132144 "float16" ,
145+ TensorContentRandom (),
133146 ),
134147 # Test non-zero padding
135148 (
@@ -142,6 +155,7 @@ class TestAvgPool2dSlice:
142155 True ,
143156 "nhwc-8h2w32c2w-2d" ,
144157 "float16" ,
158+ TensorContentRandom (),
145159 ),
146160 (
147161 [1 , 8 , 8 , 32 ],
@@ -153,6 +167,7 @@ class TestAvgPool2dSlice:
153167 True ,
154168 "nhwc-8h2w32c2w-2d" ,
155169 "float16" ,
170+ TensorContentRandom (),
156171 ),
157172 (
158173 [1 , 8 , 8 , 32 ],
@@ -164,6 +179,7 @@ class TestAvgPool2dSlice:
164179 True ,
165180 "nhwc-8h2w32c2w-2d" ,
166181 "float16" ,
182+ TensorContentRandom (),
167183 ),
168184 (
169185 [1 , 8 , 8 , 32 ],
@@ -175,6 +191,7 @@ class TestAvgPool2dSlice:
175191 True ,
176192 "nhwc-8h2w32c2w-2d" ,
177193 "float16" ,
194+ TensorContentRandom (),
178195 ),
179196 # Test n11c-1024c-2d layout which will require input and output to have different layout
180197 (
@@ -187,6 +204,7 @@ class TestAvgPool2dSlice:
187204 True ,
188205 "n11c-1024c-2d" ,
189206 "float16" ,
207+ TensorContentRandom (),
190208 ),
191209 (
192210 [1 , 1 , 1 , 2048 ],
@@ -198,6 +216,7 @@ class TestAvgPool2dSlice:
198216 True ,
199217 "n11c-1024c-2d" ,
200218 "float16" ,
219+ TensorContentRandom (),
201220 ),
202221 (
203222 [1 , 1 , 1 , 2048 ],
@@ -209,6 +228,7 @@ class TestAvgPool2dSlice:
209228 True ,
210229 "n11c-1024c-2d" ,
211230 "float16" ,
231+ TensorContentRandom (),
212232 ),
213233 (
214234 [1 , 1 , 1 , 2048 ],
@@ -220,6 +240,7 @@ class TestAvgPool2dSlice:
220240 True ,
221241 "n11c-1024c-2d" ,
222242 "float16" ,
243+ TensorContentRandom (),
223244 ),
224245 ]
225246
@@ -236,6 +257,7 @@ class TestAvgPool2dSlice:
236257 count_include_pad ,
237258 output_layout ,
238259 dtype ,
260+ input_tensor_populator ,
239261 ) = tvm .testing .parameters (* _multitest_params , ids = _param_ids )
240262
241263 @tvm .testing .fixture
0 commit comments