From cfc8269b1c2772d518dabe6eb56b8c72119c9b17 Mon Sep 17 00:00:00 2001 From: Kimish Patel Date: Tue, 27 Oct 2020 10:40:44 -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: 8b4ee6ed7a3c6a0c6b6a4aa1e50ce14e94d2eee6 --- 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 b2f193299089..bde4067d45dc 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() {