MCPcopy Create free account
hub / github.com/alibaba/MNN / run

Method run

test/op/StridedSliceTest.cpp:175–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173public:
174 virtual ~SplitC4Test() = default;
175 virtual bool run(int precision) {
176 int N = 1; int C = 32; int W = 3; int H = 4;
177 auto x = _Input({N, C, H, W}, NCHW, halide_type_of<int>());
178 auto xPtr = x->writeMap<int>();
179 for (int x=0; x<N; ++x) {
180 for (int y=0; y<C; ++y) {
181 for (int z=0; z<H; ++z) {
182 for (int w=0; w<W; ++w) {
183 auto pos = x * C * H * W + y * H * W + z * W + w;
184 xPtr[pos] = pos;
185 }
186 }
187 }
188 }
189 x = _Convert(x, NC4HW4);
190 x.fix(VARP::CONSTANT);
191
192 auto y = _Split(x, {2}, 1)[1];
193 auto yInfo = y->getInfo();
194 if (yInfo->dim[0] != N || yInfo->dim[1] != C/2 || yInfo->dim[2] != H || yInfo->dim[3] != W) {
195 FUNC_PRINT(1);
196 return false;
197 }
198 y = _Add(y, _Scalar<int>(0));
199 y = _Convert(y, NCHW);
200 {
201 auto yPtr = y->readMap<int>();
202 for (int x=0; x<N; ++x) {
203 for (int y=0; y<C/2; ++y) {
204 for (int z=0; z<H; ++z) {
205 for (int w=0; w<W; ++w) {
206 auto pos = x * C/2 * H * W + y * H * W + z * W + w;
207 auto value = x * C * H * W + (y+C/2) * H * W + z * W + w;
208 if (yPtr[pos] != value) {
209 FUNC_PRINT(1);
210 return false;
211 }
212 }
213 }
214 }
215 }
216 }
217 if (1 == N) {
218 auto y2 = _RasterRaw({x}, {C/2*H*W, 0, 0, 1, 0, 0, 0, 1, 1, 1, C/2*H*W}, {N, C/2, H, W}, halide_type_of<int>(), NC4HW4);
219 y2 = _Add(y2, _Scalar<int>(0));
220 y2 = _Convert(y2, NCHW);
221 auto yPtr = y2->readMap<int>();
222 for (int x=0; x<N; ++x) {
223 for (int y=0; y<C/2; ++y) {
224 for (int z=0; z<H; ++z) {
225 for (int w=0; w<W; ++w) {
226 auto pos = x * C/2 * H * W + y * H * W + z * W + w;
227 auto value = x * C * H * W + (y+C/2) * H * W + z * W + w;
228 if (yPtr[pos] != value) {
229 FUNC_PRINT(1);
230 return false;
231 }
232 }

Callers

nothing calls this directly

Calls 7

_InputFunction · 0.85
_ConvertFunction · 0.85
_SplitFunction · 0.85
_AddFunction · 0.85
_RasterRawFunction · 0.85
fixMethod · 0.80
getInfoMethod · 0.45

Tested by

no test coverage detected