#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION) #pragma once #include #include namespace c10 { struct StorageImpl; class DataPtr; } // namespace c10 namespace c10::impl::cow { // Creates a Copy-on-write (COW) clone of the given storage. This will also // convert the given storage into a COW storage if it is not COW already. // // Converting the storage into a COW storage will not be successful if the // storage's DataPtr has some context (`DataPtr::get_context()`) which is not // equal to the data pointer (`DataPtr::get()`). In this case, a nullptr is // returned. C10_API c10::intrusive_ptr lazy_clone_storage( StorageImpl& storage); // Check if a storage has a simple DataPtr with no abnormal context C10_API bool has_simple_data_ptr(const c10::StorageImpl& storage); // Check if a DataPtr is COW C10_API bool is_cow_data_ptr(const c10::DataPtr& data_ptr); // MaterializeFn for COW storages. Copies shared data on write. C10_API void materialize_cow(StorageImpl* storage); } // namespace c10::impl::cow #else #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined." #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)