| 265 | } |
| 266 | |
| 267 | void DataParser::parse_shape(const std::string& name, const std::string& str) { |
| 268 | //! {d0,d1,..,dn} |
| 269 | mgb_assert( |
| 270 | "{" == str.substr(0, 1), |
| 271 | "invalid value: %s for parse_shape, valid format: {d0,d1,..,dn}\n", |
| 272 | str.c_str()); |
| 273 | megdnn::SmallVector<size_t> shape; |
| 274 | std::string shape_size = ""; |
| 275 | for (size_t i = 0; i < str.size(); ++i) { |
| 276 | char c = str[i]; |
| 277 | if ('{' == c || ' ' == c) { |
| 278 | continue; |
| 279 | } else if (',' == c || '}' == c) { |
| 280 | shape.push_back(std::stoul(shape_size)); |
| 281 | shape_size = ""; |
| 282 | if ('}' == c) { |
| 283 | break; |
| 284 | } |
| 285 | } else { |
| 286 | shape_size += c; |
| 287 | } |
| 288 | } |
| 289 | mgb::HostTensorND hv(mgb::CompNode::default_cpu(), shape); |
| 290 | mgb::HostTensorStorage storage(mgb::CompNode::default_cpu()); |
| 291 | hv.only_reset_raw_storage(storage); |
| 292 | inputs.insert(std::make_pair(name, std::move(hv))); |
| 293 | } |
nothing calls this directly
no test coverage detected