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

Method run

test/speed/GridSampleSpeed.cpp:33–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 virtual ~GridSampleSpeed() = default;
32
33 virtual bool run(int precision) {
34 const int batch = BATCH;
35 const int inHeight = HEIGHT;
36 const int inWidth = WIDTH;
37 const int outHeight = HEIGHT;
38 const int outWidth = WIDTH;
39 const int depth = DEPTH;
40 auto input = _Input({batch, depth, inHeight, inWidth}, NCHW);
41 auto grid = _Input({batch, outHeight, outWidth, 2}, NHWC);
42
43 std::vector<InterpolationMethod> modes({BILINEAR});
44 std::vector<GridSamplePaddingMode> paddingModes({GRID_SAMPLE_PADDING_ZEROS});
45 std::vector<bool> alignCornersVec({false});
46
47 std::vector<float> expectedOutput(batch * outHeight * outWidth * depth);
48 for (auto mode : modes) {
49 std::string modeStr = mode == BILINEAR ? "bilinear" : "nearest";
50 for (auto paddingMode : paddingModes) {
51 std::string paddingModeStr = paddingMode == GRID_SAMPLE_PADDING_ZEROS ?
52 "zeros" : (paddingMode == GRID_SAMPLE_PADDING_BORDER ? "border"
53 : "reflection");
54 for (auto alignCorners : alignCornersVec) {
55 std::string alignCornersStr = alignCorners ? "true" : "false";
56
57// grid->unMap();
58// input->unMap();
59// input = _Convert(input, NC4HW4);
60 auto output = _GridSample(input, grid, mode, paddingMode, alignCorners);
61 MNN_PRINT("Test GridSample for NCHW (%d, %d, %d, %d) x %d with setting %s %s %s \n",
62 BATCH, DEPTH, HEIGHT, WIDTH, TIME,
63 modeStr.c_str(), paddingModeStr.c_str(), alignCornersStr.c_str());
64 {
65 AUTOTIME;
66 for (int i = 0; i < TIME; ++i) {
67 auto inputPtr = input->writeMap<float>();
68 auto gridPtr = grid->writeMap<float>();
69
70 output->readMap<float>();
71 }
72 }
73 }
74 }
75 }
76 return true;
77 }
78};
79
80MNNTestSuiteRegister(GridSampleSpeed, "speed/GridSample");

Callers

nothing calls this directly

Calls 3

_InputFunction · 0.85
_GridSampleFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected