| 257 | } |
| 258 | |
| 259 | PersistentCache::Blob AlgoChooserProfileCache::Key::build_blob() const { |
| 260 | auto&& ret = m_blob_storage; |
| 261 | if (!m_blob_storage.empty()) |
| 262 | return {ret.data(), ret.size()}; |
| 263 | |
| 264 | ret.reserve(sizeof(TensorLayout) * 3 * m_inp_layouts_size + m_param_size); |
| 265 | for (size_t i = 0; i < m_inp_layouts_size; ++i) { |
| 266 | auto&& ly = m_inp_layouts_ptr[i]; |
| 267 | for (size_t j = 0; j < ly.ndim; ++j) { |
| 268 | if (j) |
| 269 | ret.push_back(','); |
| 270 | ret.append(std::to_string(ly.shape[j])); |
| 271 | } |
| 272 | if (!ly.is_contiguous()) { |
| 273 | ret.push_back(';'); |
| 274 | for (size_t j = 0; j < ly.ndim; ++j) { |
| 275 | if (j) |
| 276 | ret.push_back(','); |
| 277 | ret.append(std::to_string(ly.stride[j])); |
| 278 | } |
| 279 | } |
| 280 | ret.push_back(';'); |
| 281 | ret.append(ly.dtype.name()); |
| 282 | ret.push_back('|'); |
| 283 | mgb_assert( |
| 284 | ly.format.is_default() || |
| 285 | (ly.format.is_lowbit_aligned() && ly.dtype.is_low_bit()), |
| 286 | "currently only default format is supported"); |
| 287 | } |
| 288 | if (m_param_size) { |
| 289 | ret.append(reinterpret_cast<const char*>(m_param), m_param_size); |
| 290 | } |
| 291 | return {ret.data(), ret.size()}; |
| 292 | } |
| 293 | |
| 294 | #undef ENGRY_FMT |
| 295 |
no test coverage detected