MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / build_blob

Method build_blob

src/core/impl/utils/persistent_cache.cpp:259–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259PersistentCache::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

Callers 2

getMethod · 0.80
putMethod · 0.80

Calls 12

to_stringFunction · 0.85
is_lowbit_alignedMethod · 0.80
is_low_bitMethod · 0.80
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45
appendMethod · 0.45
is_contiguousMethod · 0.45
nameMethod · 0.45
is_defaultMethod · 0.45

Tested by

no test coverage detected