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

Method run

test/op/SoftmaxTest.cpp:253–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251public:
252 virtual ~SoftmaxInt8Test() = default;
253 virtual bool run(int precision) {
254 // testcase 1
255 {
256 std::vector<int> dimensions = {2, 2, 3, 4};
257 auto input = _Input(dimensions, NCHW);
258 input->setName("input_tensor");
259 // set input data
260 float inputData[] = {7.2129,5.9265,3.7045,3.1111,4.5548,7.5229,4.2968,7.9198,4.2842,9.7357,8.6082,
261 4.2730,3.2067,9.5121,4.6973,7.1634,8.2003,6.7548,4.6160,9.3058,3.0313,7.5376,7.6309,3.8655,
262 5.4967,5.6967,8.1985,5.9047,7.1774,6.6393,5.9027,3.9387,6.5073,4.4462,4.7199,3.6948,7.4889,
263 9.5616,5.1855,3.1104,3.7267,5.2157,9.8103,9.8155,6.3442,8.2376,3.6553,5.3901};
264
265 const float quantScales[] = {0.102, 0.00784};
266 const float zeroPoints[] = {1., 2.};
267 input->writeScaleMap(quantScales[0], zeroPoints[0]);
268 auto inputPtr = input->writeMap<float>();
269 memcpy(inputPtr, inputData, 48 * sizeof(float));
270 input->unMap();
271 VARP output;
272 for (int axis = 0; axis < dimensions.size(); ++axis) {
273 output = _Softmax(input, axis);
274 output->writeScaleMap(quantScales[1], zeroPoints[1]);
275 auto gotOutput = output->readMap<float>();
276
277
278 bool result = checkProbAndOrder((float*)gotOutput, outputs[axis], orders[axis], 48, dimensions, axis);
279 if (!result) {
280 MNN_PRINT("when axis = %d, SoftmaxInt8 case1 failed!\n", axis);
281 return false;
282 }
283 }
284 }
285 return true;
286 }
287};
288MNNTestSuiteRegister(SoftmaxTest, "op/softmax");
289MNNTestSuiteRegister(SoftmaxInt8Test, "op/softmaxInt8");

Callers

nothing calls this directly

Calls 6

_InputFunction · 0.85
_SoftmaxFunction · 0.85
checkProbAndOrderFunction · 0.85
unMapMethod · 0.80
setNameMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected