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

Function main

tools/cpp/ModuleBasic.cpp:106–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104 return result;
105}
106int main(int argc, char *argv[]) {
107 if (argc < 3) {
108 MNN_PRINT("=======================================================================================================================================\n");
109 MNN_ERROR("Usage: ./ModuleBasic.out ${test.mnn} ${Dir} [runMask] [forwardType] [runLoops] [numberThread] [precision | memory] [cacheFile] [cpuIds] [enableKleidiAI]\n");
110 MNN_PRINT("=======================================================================================================================================\n");
111 return 0;
112 }
113 BackendConfig backendConfigTmp;
114 auto _executor = Executor::newExecutor(MNN_FORWARD_CPU, backendConfigTmp, 1);
115 ExecutorScope _s(_executor);
116
117 std::string modelName = argv[1];
118 std::string directName = argv[2];
119 MNN_PRINT("Test %s from input info: %s\n", modelName.c_str(), directName.c_str());
120 std::map<std::string, float> inputInfo;
121 std::map<std::string, std::vector<int>> inputShape;
122 std::vector<std::string> inputNames;
123 std::vector<std::string> outputNames;
124 bool checkOutput = false;
125 int runMask = 0;
126 if (argc > 3) {
127 runMask = atoi(argv[3]);
128 if (runMask & 1) {
129 _initDebug();
130 }
131 if (runMask & 2) {
132 _initTensorStatic();
133 }
134 }
135 int repeatNumber = 2;
136 bool shapeMutable = true;
137 std::vector<VARP> inputs;
138 std::vector<VARP> outputs;
139 if (runMask & 128) {
140 MNN_PRINT("Use input.mnn and output.mnn for test\n");
141 inputs = MNN::Express::Variable::load((directName + "/input.mnn").c_str());
142 outputs = MNN::Express::Variable::load((directName + "/output.mnn").c_str());
143 if (inputs.size() > 0 && outputs.size() > 0) {
144 MNN_PRINT("Has input.mnn, use input.mnn and output.mnn instead of json\n");
145 }
146 for (auto v : inputs) {
147 inputNames.emplace_back(v->name());
148 }
149 for (auto v : outputs) {
150 outputNames.emplace_back(v->name());
151 }
152 checkOutput = outputs.size() > 0;
153 }
154 // Call Time / Per Second
155 float freq = 0.0f;
156 int cpuDecreaseRate = -1;
157 int kvAdd = 0;
158 if (inputNames.empty()) {
159 rapidjson::Document document;
160 std::ostringstream jsonNameOs;
161 jsonNameOs << directName << "/input.json";
162 std::ifstream fileNames(jsonNameOs.str().c_str());
163 std::ostringstream output;

Callers

nothing calls this directly

Calls 15

_initTensorStaticFunction · 0.85
_InputFunction · 0.85
_ConvertFunction · 0.85
_CloneFunction · 0.85
_initTimeTraceFunction · 0.85
HasMemberMethod · 0.80
setHintPtrMethod · 0.80
find_last_ofMethod · 0.80
substrMethod · 0.80
fixMethod · 0.80
durationInUsMethod · 0.80
updateCacheMethod · 0.80

Tested by

no test coverage detected