Fix CPUCaching allocator guard bug (#46922)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/46922

Earlier bug wrongly captures the previous value to be saved.

Test Plan: cpu_caching_allocator_test

Reviewed By: dreiss

Differential Revision: D24566514

fbshipit-source-id: 734a4c1f810bbec16fe007f31fffa360898955ac
This commit is contained in:
Kimish Patel 2020-10-28 10:04:09 -07:00 committed by Facebook GitHub Bot
parent c3fc17b48e
commit cbf90dafe1

View file

@ -95,8 +95,8 @@ CPUCachingAllocator* GetThreadLocalCachingAllocator() {
WithCPUCachingAllocatorGuard::WithCPUCachingAllocatorGuard(
CPUCachingAllocator* allocator) {
caching_allocator_ptr = allocator;
prev_caching_allocator_ptr_ = GetThreadLocalCachingAllocator();
caching_allocator_ptr = allocator;
}
WithCPUCachingAllocatorGuard::~WithCPUCachingAllocatorGuard() {