[Core ML] Attemp to fix the OOM issue (#73750)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/73750
My intuition is that the delay release of input and intermediate tensors may cause memory being accumulated. Especially for camera-based memory intensive situations, the runloop is full of all sorts of events. Thus, default `autoreleasepool` may not be efficient. The fix here is to manually wrap the prediction call inside a `autoreleasepool` to force releasing intermediate objects. Apple's doc - https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAutoreleasePools.html
ghstack-source-id: 150411705
Test Plan:
- CI
- Check the OOM data in QE
Reviewed By: dreiss
Differential Revision: D34605399
fbshipit-source-id: 413564d7ec560082a6572c5542e2b4da433ee62f
(cherry picked from commit ea2b613c16ffad329ccd463a44d6635db0681def)