| 92 | } |
| 93 | |
| 94 | static bool parseDims(const std::string& s, std::vector<std::vector<int>>& out) { |
| 95 | auto isLegal = [](char c) { |
| 96 | return c == 'x' || c == '_' || (c >= '0' && c <= '9'); |
| 97 | }; |
| 98 | bool allLegal = std::all_of(s.begin(), s.end(), isLegal); |
| 99 | if(!allLegal) { |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | out.clear(); |
| 104 | std::stringstream ss(s); |
| 105 | std::string segment; |
| 106 | MNN_PRINT("param dims: %s\n", s.c_str()); |
| 107 | while (std::getline(ss, segment, '_')) { |
| 108 | if (segment.empty()) { |
| 109 | MNN_ERROR("%s parse error, format should be like 1x3x512x512_1x256\n", s.c_str()); |
| 110 | return false; |
| 111 | } |
| 112 | std::vector<int> dims; |
| 113 | std::stringstream inner(segment); |
| 114 | std::string token; |
| 115 | |
| 116 | while (std::getline(inner, token, 'x')) { |
| 117 | if (token.empty()) { |
| 118 | MNN_ERROR("%s parse error, format should be like 1x3x512x512_1x256\n", s.c_str()); |
| 119 | return false; |
| 120 | } |
| 121 | int val = std::stoi(token); |
| 122 | dims.push_back(val); |
| 123 | } |
| 124 | if (dims.empty()) { |
| 125 | MNN_ERROR("%s parse error, format should be like 1x3x512x512_1x256\n", s.c_str()); |
| 126 | return false; |
| 127 | } |
| 128 | out.push_back(dims); |
| 129 | } |
| 130 | return true; |
| 131 | } |
| 132 | |
| 133 | static bool checkSystem() { |
| 134 | #ifdef _WIN32 |