pytorch
9be4c75f - [JIT] Add Reinplacing to MKLDNN Subgraphs (#53908)

Commit
3 years ago
[JIT] Add Reinplacing to MKLDNN Subgraphs (#53908) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/53908 This adds reinplacing to MKLDNN Subgraphs so that we replace `aten::add` with `aten::add_`. Normally you would have to prove device and dtype, but we know that already, and because we have explicit broadcast nodes for other reasons we dont have to prove that the output shape of add is the same as inputs. Ive tested correctness on resnet, I'm going to do more extensive testing as well. When I benchmarked the "unsafe" version (always inplace) I saw average speedups of ~16% for both Single threaded and Multithreaded. I dont think the "safe" version will be far beyond; when I looked at resnet for example every `add` and `relu` were reinplaced. Theres some question of reusing other alias / liveness / inplacing passes in SR. I thought about it, however I didnt want to add a cross-dependency between very different parts of the code base with a bunch of different assumptions. The logic here is also covering a simpler case and does not add much complexity IMO. Test Plan: Imported from OSS Reviewed By: Krovatkin Differential Revision: D27132969 Pulled By: eellison fbshipit-source-id: 121a38daaedf01363f6b66a814beaaa72a0ab0dc
Author
Elias Ellison
Parents
Loading