Improve HIPify performance (#14803)
authorEdward Yang <ezyang@fb.com>
Wed, 5 Dec 2018 18:57:00 +0000 (10:57 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 5 Dec 2018 19:00:03 +0000 (11:00 -0800)
commit999690ff3d1e04ff3d23944a230f699eb88e01db
treed5feb268f58f06e0d2f4f5cf19c46fe0493717d0
parentbe47470c91e467d8bddbc0e07f099cf2a200e5c0
Improve HIPify performance (#14803)

Summary:
```
    Improve performance of pyHIPIFY

    Changes:
    - Pre-compile regexes, don't use regexes when it's not necessary
      (this saves us ~15%)
    - Compile all substitutions for mappings into a single, non-backtracking
      regex using a Trie.  This gives big savings.

    Before, running pyHIPIFY on all files took 15.8s.  Now it takes 3.9s.
```

Stacked on #14769
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14803

Differential Revision: D13342620

Pulled By: ezyang

fbshipit-source-id: 1cfa36b3236bbe24d07080a31cc788a52d740f40
tools/amd_build/pyHIPIFY/cuda_to_hip_mappings.py
tools/amd_build/pyHIPIFY/hipify_python.py