pytorch
4d6f98ec - [PyTorch] Avoid using std::regex for device string parsing in Device.cpp (#63204)

Commit
3 years ago
[PyTorch] Avoid using std::regex for device string parsing in Device.cpp (#63204) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63204 Currently, `std::regex` is used for parsing device strings. This is undesirable for a few reasons. 1. Increases binary size 2. Slows down model loading 3. Potentially uses more memory at runtime 4. Takes marginally longer time to build code that uses std::regex v/s not using std::regex This change avoids the use of `std::regex` for parsing the device string since we don't need to. ghstack-source-id: 136006963 Test Plan: ### AI Bench Runs **Before this change:** 1. Model Load time: [252ms](https://www.internalfb.com/intern/aibench/details/332471502816548) 2. Model unload time: 3.5ms **After this change:** 1. Model Load time: [240ms](https://www.internalfb.com/intern/aibench/details/652195589031318), which is an approx 5% reduction for the current model. I suspect percentage wise, it will be larger for smaller models since this is a fixed cost reduction. 2. Model unload time: 3.3ms (probably too small to be meaningfully impactful to an end user). ### BSB Results ``` D30281388-V1 (https://www.internalfb.com/intern/diff/D30281388/?dest_number=135713848) messenger-pika-optimized-device: Succeeded Change in Download Size for arm64 + 3x assets variation: -7.1 KiB Change in Uncompressed Size for arm64 + 3x assets variation: -17.6 KiB Mbex Comparison: https://our.intern.facebook.com/intern/mbex/bsb:551399955987465@base/bsb:551399955987465@diff/ ``` Reviewed By: raziel Differential Revision: D30281388 fbshipit-source-id: 4d998e9f313e6366d9d89a6a73cd090ddfb059fc
Author
Parents
Loading