| 17 | # serial='-s 30.x.x.x:x' # Specify test phone ip address |
| 18 | |
| 19 | def test(model_root_dir, parameters): |
| 20 | global gRight |
| 21 | print("all parameters: ", parameters) |
| 22 | root_dir = model_root_dir + '/TestResource' |
| 23 | print('root: ', root_dir) |
| 24 | for name in os.listdir(root_dir): |
| 25 | if name == '.DS_Store': |
| 26 | continue |
| 27 | modelName = os.path.join(root_dir, name, 'temp.bin') |
| 28 | inputName = os.path.join(root_dir, name, 'input_0.txt') |
| 29 | outputName = os.path.join(root_dir, name, 'output.txt') |
| 30 | print(modelName) |
| 31 | run_cmd(['adb', serial, 'push', modelName, '/data/local/tmp/MNN/temp.bin']) |
| 32 | run_cmd(['adb', serial, 'push', inputName, '/data/local/tmp/MNN/input_0.txt']) |
| 33 | run_cmd(['adb', serial, 'push', outputName, '/data/local/tmp/MNN/output.txt']) |
| 34 | message = run_cmd(['adb', serial, 'shell', '\"cd /data/local/tmp/MNN&&export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH && ./testModel.out temp.bin input_0.txt output.txt %s\"' %(parameters)]) |
| 35 | print(str(message)) |
| 36 | if (message.find('Correct') < 0): |
| 37 | gWrong.append(modelName) |
| 38 | else: |
| 39 | gRight += 1 |
| 40 | root_dir = model_root_dir + '/OpTestResource' |
| 41 | print('root: ', root_dir) |
| 42 | for name in os.listdir(root_dir): |
| 43 | if name == '.DS_Store': |
| 44 | continue |
| 45 | modelName = os.path.join(root_dir, name, 'temp.bin') |
| 46 | inputName = os.path.join(root_dir, name, 'input_0.txt') |
| 47 | outputName = os.path.join(root_dir, name, 'output_0.txt') |
| 48 | print(modelName) |
| 49 | run_cmd(['adb', serial, 'push', modelName, '/data/local/tmp/MNN/temp.bin']) |
| 50 | run_cmd(['adb', serial, 'push', inputName, '/data/local/tmp/MNN/input_0.txt']) |
| 51 | run_cmd(['adb', serial, 'push', outputName, '/data/local/tmp/MNN/output_0.txt']) |
| 52 | message = run_cmd(['adb', serial, 'shell', '\"cd /data/local/tmp/MNN&&export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH && ./testModel.out temp.bin input_0.txt output_0.txt %s\"' % (parameters)]) |
| 53 | print(message) |
| 54 | if (message.find('Correct') == -1): |
| 55 | gWrong.append(modelName) |
| 56 | else: |
| 57 | gRight += 1 |
| 58 | # total model test |
| 59 | root_dir = os.path.join(model_root_dir, 'TestWithDescribe') |
| 60 | print('Model Root Path: ' + root_dir + '\n') |
| 61 | for name in os.listdir(root_dir): |
| 62 | if name == '.DS_Store': |
| 63 | continue |
| 64 | modelDir = os.path.join(root_dir, name) |
| 65 | modelName = os.path.join(modelDir, 'temp.bin') |
| 66 | if not os.path.exists(modelName): |
| 67 | continue |
| 68 | print(run_cmd(['adb', serial, 'push', modelDir, '/data/local/tmp/MNN/'])) |
| 69 | print(modelDir) |
| 70 | print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Running...") |
| 71 | message = run_cmd(['adb', serial, 'shell', '\"cd /data/local/tmp/MNN&&export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH && ./testModelWithDescribe.out %s/temp.bin %s/config.txt %s\"' %(name, name, parameters)]) |
| 72 | run_cmd(['adb', serial, 'shell', 'rm -rf /data/local/tmp/MNN/%s'%(name)]) |
| 73 | if (message.find('Correct') == -1): |
| 74 | gWrong.append(modelDir) |
| 75 | else: |
| 76 | gRight += 1 |