Skip to content

Commit f8eead2

Browse files
[slimtensor] Add non-owning storage mode for wrapping external memory (pytorch#16801)
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: pytorch#16772 by @Gasoonjia ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/112/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/112/head Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/111/orig Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/112/orig Differential Revision: [D91202898](https://our.internmc.facebook.com/intern/diff/D91202898/) @diff-train-skip-merge --------- Co-authored-by: gasoonjia <gasoonjia@icloud.com> Co-authored-by: Gasoonjia <gasoonjia@meta.com>
1 parent 37aa87e commit f8eead2

2 files changed

Lines changed: 414 additions & 0 deletions

File tree

‎backends/aoti/slim/core/Storage.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,17 @@ class MaybeOwningStorage {
231231
}
232232
}
233233

234+
/// Constructs non-owning storage with external memory.
235+
/// @param device The device where the data resides.
236+
/// @param data Pointer to external memory (not owned by this storage).
237+
/// @param nbytes Size of the external memory in bytes.
238+
MaybeOwningStorage(const c10::Device& device, void* data, size_t nbytes)
239+
: device_(device),
240+
data_(data),
241+
capacity_(nbytes),
242+
deleter_(detail::noop),
243+
is_owning_(false) {}
244+
234245
/// Default constructor is deleted - storage must have a device.
235246
MaybeOwningStorage() = delete;
236247

0 commit comments

Comments
 (0)