// // NormalizeTest.cpp // MNNTests // // Created by MNN on 2021/10/22. // Copyright © 2018, Alibaba Group Holding Limited // #include #include #include #include "MNNTestSuite.h" #include "TestUtils.h" using namespace MNN::Express; class NormalizeTest : public MNNTestCase { public: static void _refNormalize(float* dst, const float* src, int batch, int channel, int area, float* scale, float eps) { // Normalize for (int b=0; bwriteMap(); memcpy(inputPtr, inpudata, 4 * sizeof(float)); input = _Convert(input, NC4HW4); std::vector scaleData = {0.5f, 0.5f}; float eps = 0.00f; auto output = _Normalize(input, 0, 0, eps, scaleData); output = _Convert(output, NCHW); std::vector expectedOutput(4); _refNormalize(expectedOutput.data(), inpudata, 1, 2, 2, scaleData.data(), eps); auto gotOutput = output->readMap(); float errorScale = precision <= MNN::BackendConfig::Precision_High ? 1 : 1000; if (!checkVectorByRelativeError(gotOutput, expectedOutput.data(), 4, 1e-5 * errorScale)) { MNN_ERROR("NormalizeTest test failed!\n"); return false; } return true; } }; MNNTestSuiteRegister(NormalizeTest, "op/normalize");