| 16 | public: |
| 17 | virtual ~SizeTest() = default; |
| 18 | bool _run(int precision, bool lazy) { |
| 19 | auto input = _Input({2, 2}, NCHW); |
| 20 | input->setName("input_tensor"); |
| 21 | // set input data |
| 22 | const float inpudata[] = {-1.0, -2.0, 3.0, 4.0}; |
| 23 | auto inputPtr = input->writeMap<float>(); |
| 24 | memcpy(inputPtr, inpudata, 4 * sizeof(float)); |
| 25 | input->unMap(); |
| 26 | auto output = _Size(input); |
| 27 | const std::vector<int> expectedOutput = {4}; |
| 28 | auto gotOutput = output->readMap<int>(); |
| 29 | if (!checkVector<int>(gotOutput, expectedOutput.data(), 1, 0)) { |
| 30 | MNN_ERROR("SizeTest test failed!\n"); |
| 31 | return false; |
| 32 | } |
| 33 | auto dims = output->getInfo()->dim; |
| 34 | if (dims.size() != 0) { |
| 35 | MNN_ERROR("SizeTest test failed!\n"); |
| 36 | return false; |
| 37 | } |
| 38 | return true; |
| 39 | } |
| 40 | virtual bool run(int precision) { |
| 41 | ExecutorScope::Current()->lazyEval = false; |
| 42 | auto res = _run(precision, false); |