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

Method test

test/op/DeconvolutionTest.cpp:198–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196
197protected:
198 static bool test(const std::string& device_name, const std::string& test_op_name,
199 vector<float>& inputData, vector<int8_t>& weightData, vector<float>& biasData, vector<float>& rightOutData,
200 int batch, int ic, int oc, int ih, int iw, PadMode mode, int pad_h, int pad_w, int kh,
201 int kw, int stride, int dilation, int group, int precision, vector<float>& scale, vector<float>& zeroPoints, vector<float>& quantScales) {
202 std::map<PadMode, Express::PaddingMode> padMap = {
203 {PadMode_CAFFE, CAFFE}, {PadMode_VALID, VALID}, {PadMode_SAME, SAME}};
204 auto input = _Input({batch, ic, ih, iw}, NCHW, halide_type_of<float>());
205 input->writeScaleMap(quantScales[0], zeroPoints[0]);
206 ::memcpy(input->writeMap<float>(), inputData.data(), inputData.size() * sizeof(float));
207 auto xC4 = _Convert(input, NC4HW4);
208 auto output = _Deconv(std::move(weightData), std::move(biasData), std::move(scale), xC4, {ic, oc}, {kw, kh}, padMap[mode], {stride, stride}, {dilation, dilation}, group, {pad_w, pad_h}, false, false, (int8_t)zeroPoints[0], (int8_t)zeroPoints[1], 127, -127);
209 output->writeScaleMap(quantScales[1], zeroPoints[1]);
210 auto y = _Convert(output, NCHW);
211 // difference below 0.5% relative error is considered correct.
212 auto outputPtr = y->readMap<float>();
213 float errorScale = precision <= MNN::BackendConfig::Precision_High ? 1 : 20;
214 if (!checkVectorByRelativeError<float>(outputPtr, rightOutData.data(), rightOutData.size(), 0.005 * errorScale)) {
215 MNN_ERROR("%s(%s) test failed: batch=%d, oc=%d, oh=%d, ow=%d!\n", test_op_name.c_str(), device_name.c_str(), y->getInfo()->dim[0], y->getInfo()->dim[1], y->getInfo()->dim[2], y->getInfo()->dim[3]);
216 return false;
217 }
218 return true;
219 }
220};
221class DeconvolutionFullTest : public DeconvolutionCommonTest {
222public:

Callers

nothing calls this directly

Calls 7

_InputFunction · 0.85
_ConvertFunction · 0.85
_DeconvFunction · 0.70
dataMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45
getInfoMethod · 0.45

Tested by

no test coverage detected