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

Class WorkspaceBundle

dnn/src/common/utils.h:274–307  ·  view source on GitHub ↗

* \brief Aligned workspace bundle. * * Each individual workspace is aligned to align_in_bytes. */

Source from the content-addressed store, hash-verified

272 * Each individual workspace is aligned to align_in_bytes.
273 */
274class WorkspaceBundle {
275public:
276 WorkspaceBundle(
277 void* ptr, SmallVector<size_t> sizes_in_bytes, size_t align_in_bytes = 512);
278 /**
279 * \returns raw workspace ptr.
280 *
281 * Note that ptr() is different than get(0), in that
282 * the result of ptr() is possibly not aligned.
283 */
284 void* ptr() const;
285 /**
286 * \returns the i-th workspace ptr (aligned)
287 */
288 void* get(size_t i) const;
289 /**
290 * \returns total size taking into account paddings to solve alignment
291 * issue.
292 */
293 size_t total_size_in_bytes() const;
294 size_t get_size(size_t i) const;
295 size_t nr_workspace() const;
296 void set(void* ptr);
297
298 Workspace get_workspace(size_t i) const {
299 return {static_cast<dt_byte*>(get(i)), get_size(i)};
300 }
301
302private:
303 void* m_ptr;
304 SmallVector<size_t> m_sizes;
305 SmallVector<size_t> m_aligned_sizes;
306 size_t m_align_in_bytes;
307};
308
309MEGDNN_CONSTEXPR std::size_t operator"" _z(unsigned long long n) {
310 return n;

Callers 15

get_bundleFunction · 0.85
get_bundleFunction · 0.85
get_bundleFunction · 0.85
get_bundleFunction · 0.85
get_bundle_nchw44Function · 0.85
get_bundleMethod · 0.85
get_wbundleMethod · 0.85
get_wbundle_computeMethod · 0.85
get_bundleMethod · 0.85
get_bundleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected