From cbf90dafe1cdb4f3f87b7a0804b601dc41bceb5b Mon Sep 17 00:00:00 2001 From: Kimish Patel Date: Wed, 28 Oct 2020 10:04:09 -0700 Subject: [PATCH] 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 --- c10/mobile/CPUCachingAllocator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c10/mobile/CPUCachingAllocator.cpp b/c10/mobile/CPUCachingAllocator.cpp index b2f19329908..bde4067d45d 100644 --- a/c10/mobile/CPUCachingAllocator.cpp +++ b/c10/mobile/CPUCachingAllocator.cpp @@ -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() {