| 38 | public: |
| 39 | virtual ~ScaleInt8Test() = default; |
| 40 | virtual bool run(int precision) { |
| 41 | auto input = _Input({1, 2, 2, 1}, NCHW); |
| 42 | input->writeScaleMap(0.0313725, 1.f); |
| 43 | // set input data |
| 44 | const float inpudata[] = {-1.0, -2.0, 3.0, 4.0}; |
| 45 | auto inputPtr = input->writeMap<float>(); |
| 46 | memcpy(inputPtr, inpudata, 4 * sizeof(float)); |
| 47 | input = _Convert(input, NC4HW4); |
| 48 | auto output = _Scale(input, 2, {2.0, 1.0}, {3.0, 4.0}); |
| 49 | output = _Convert(output, NCHW); |
| 50 | output->writeScaleMap(0.0628, 1.f); |
| 51 | const std::vector<float> expectedOutput = {1, -1, 7, 8}; |
| 52 | auto gotOutput = output->readMap<float>(); |
| 53 | if (!checkVector<float>(gotOutput, expectedOutput.data(), 4, 1e-1)) { |
| 54 | MNN_ERROR("ScaleTestInt8 test failed!\n"); |
| 55 | return false; |
| 56 | } |
| 57 | return true; |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | MNNTestSuiteRegister(ScaleTest, "op/scale"); |