Input: TYPE[D1,D2,...DN]
| 143 | |
| 144 | // Input: TYPE[D1,D2,...DN] |
| 145 | ArrayShape ArrayShapeFromString(const std::string& s) { |
| 146 | Log("Array shape from string: " + s); |
| 147 | Check(s.find('(') == std::string::npos, "Tuple shape is not supported"); |
| 148 | std::regex shape_r("([^\\[]+)\\[(.*)\\]"); |
| 149 | std::smatch match; |
| 150 | Check(std::regex_match(s, match, shape_r), "Shape not found"); |
| 151 | std::string type = match[1]; |
| 152 | std::string dims = match[2]; |
| 153 | PrimitiveType ptype = PrimitiveTypeFromString(type); |
| 154 | std::istringstream dims_stream(dims); |
| 155 | std::string dim; |
| 156 | std::vector<int> dimensions; |
| 157 | while (std::getline(dims_stream, dim, ',')) { |
| 158 | dimensions.push_back(std::stoi(dim)); |
| 159 | } |
| 160 | return {ptype, dimensions}; |
| 161 | } |
| 162 | |
| 163 | // E.g. (f32[10,20], u32[]) |
| 164 | TupleShape TupleShapeFromString(std::string s) { |
no test coverage detected