From b3fbd3eebf50e11f6c9af1f7d74bf295dcb2ffd5 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Fri, 8 Feb 2019 09:29:59 -0800 Subject: Deduplicate instances caching allocator, so that we only have one instance. (#16720) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/16720 I'm taking the deduplication slowly because there is something here that is causing problems, and I want to figure out what it is. Reviewed By: dzhulgakov Differential Revision: D13943194 fbshipit-source-id: cbc08fee5862fdcb393b9dd5b1d2ac7250f77c4b --- c10/cuda/CUDACachingAllocator.cpp | 11 ++--------- c10/cuda/CUDACachingAllocator.h | 6 ------ 2 files changed, 2 insertions(+), 15 deletions(-) (limited to 'c10') diff --git a/c10/cuda/CUDACachingAllocator.cpp b/c10/cuda/CUDACachingAllocator.cpp index 75faf16741..a24df498ae 100644 --- a/c10/cuda/CUDACachingAllocator.cpp +++ b/c10/cuda/CUDACachingAllocator.cpp @@ -660,21 +660,14 @@ std::shared_ptr getIpcDevPtr(std::string handle) { return sp; } -Legacy::Legacy() - : _impl(new THCCachingAllocator()) {} - -Legacy::~Legacy() { - delete _impl; -} - cudaError_t Legacy::Alloc(void** refPtr, size_t nbytes, cudaStream_t stream) { - _impl->malloc(refPtr, nbytes, stream); + caching_allocator.malloc(refPtr, nbytes, stream); return cudaSuccess; } cudaError_t Legacy::Free(void* ptr) { - _impl->free(ptr); + caching_allocator.free(ptr); return cudaSuccess; } diff --git a/c10/cuda/CUDACachingAllocator.h b/c10/cuda/CUDACachingAllocator.h index 43082d10b1..f30036f545 100644 --- a/c10/cuda/CUDACachingAllocator.h +++ b/c10/cuda/CUDACachingAllocator.h @@ -47,14 +47,8 @@ struct THCCachingAllocator; class C10_CUDA_API Legacy { public: - Legacy(); - ~Legacy(); - cudaError_t Alloc(void** refPtr, size_t nbytes, cudaStream_t stream); cudaError_t Free(void* ptr); - - private: - THCCachingAllocator* _impl; }; } // namespace CUDACachingAllocator -- cgit v1.2.3