3 #include <unordered_map> 6 #include <libshm_windows/libshm.h> 9 void libshm_init(
const char *manager_exec_path) {
12 static void deleteTHManagedMapAllocator(
void* ptr) {
13 delete static_cast<THManagedMapAllocator*
>(ptr);
16 at::DataPtr THManagedMapAllocator::makeDataPtr(
const char* manager_handle,
const char* filename,
int flags, ptrdiff_t size) {
17 auto* context =
new THManagedMapAllocator(manager_handle, filename, flags, size);
18 return {context->data(), context, &deleteTHManagedMapAllocator, at::kCPU};
21 THManagedMapAllocator* THManagedMapAllocator::fromDataPtr(
const at::DataPtr& dptr) {
22 return dptr.cast_context<THManagedMapAllocator>(&deleteTHManagedMapAllocator);