| 236 | using namespace MNN::Express; |
| 237 | |
| 238 | static std::vector<VARP> getModuleInputs(std::string file, const Module::Info* netInfo, std::vector<std::string> inputNames, std::vector<VARP> varInputs = {}) { |
| 239 | #define LOAD_DATA(TYPE)\ |
| 240 | std::ostringstream fileNameOs;\ |
| 241 | fileNameOs << file << "/" << inputName << ".txt";\ |
| 242 | auto fileName = fileNameOs.str();\ |
| 243 | std::ifstream inputOs(fileName.c_str());\ |
| 244 | if (inputOs.fail()) {\ |
| 245 | MNN_ERROR("TESTERROR Can't open %s\n", fileName.c_str());\ |
| 246 | continue;\ |
| 247 | }\ |
| 248 | for (int i=0; i<info->size; ++i) {\ |
| 249 | double tempValue;\ |
| 250 | inputOs >> tempValue;\ |
| 251 | ptr[i] = tempValue;\ |
| 252 | }\ |
| 253 | |
| 254 | #define LOAD_DATA_SHAPE() \ |
| 255 | std::ostringstream file_name_os;\ |
| 256 | file_name_os << file << "/input.json";\ |
| 257 | auto file_name = file_name_os.str();\ |
| 258 | std::ifstream input_os(file_name.c_str());\ |
| 259 | if (input_os.fail()) {\ |
| 260 | MNN_ERROR("Error: input.json does not exit in %s, use default shape.\n", file.c_str());\ |
| 261 | } else {\ |
| 262 | rapidjson::Document document;\ |
| 263 | std::ostringstream json_os;\ |
| 264 | json_os << input_os.rdbuf();\ |
| 265 | document.Parse(json_os.str().c_str());\ |
| 266 | if (document.HasParseError()) {\ |
| 267 | MNN_ERROR("Invalid json: %s\n", file_name.c_str());\ |
| 268 | }\ |
| 269 | auto cfgObj = document.GetObject();\ |
| 270 | if (cfgObj.HasMember("inputs")) {\ |
| 271 | auto inputsInfo = document["inputs"].GetArray();\ |
| 272 | for (auto iter = inputsInfo.begin(); iter !=inputsInfo.end(); iter++) {\ |
| 273 | auto obj = iter->GetObject();\ |
| 274 | std::string name = obj["name"].GetString();\ |
| 275 | if (obj.HasMember("shape")) {\ |
| 276 | auto dims = obj["shape"].GetArray();\ |
| 277 | std::vector<int> shapes;\ |
| 278 | for (auto iter = dims.begin(); iter != dims.end(); iter++) {\ |
| 279 | shapes.emplace_back(iter->GetInt());\ |
| 280 | }\ |
| 281 | dyInputShape.insert(std::make_pair(name, shapes));\ |
| 282 | }\ |
| 283 | }\ |
| 284 | }\ |
| 285 | else {\ |
| 286 | MNN_ERROR("input.json must have inputs infomation!\n");\ |
| 287 | }\ |
| 288 | }\ |
| 289 | |
| 290 | MNN_ASSERT(netInfo != nullptr || varInputs.size() > 0); |
| 291 | auto sizeInput = 1; |
| 292 | Dimensionformat dimFormat = NCHW; |
| 293 | std::vector<Variable::Info> inputsInfo; |
| 294 | if (netInfo) { |
| 295 | sizeInput = netInfo->inputs.size(); |
no test coverage detected