-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add lowering pass for rsqrt operator - Add unpack rsqrt lowering pass - Add test cases for positive inputs, int and float - Add references to new function in headers and BUILD files * Added UnpackRsqrt to lowering passes list
- Loading branch information
Showing
6 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "torch/csrc/jit/passes/subgraph_rewrite.h" | ||
|
||
#include "core/util/prelude.h" | ||
|
||
namespace torch_tensorrt { | ||
namespace core { | ||
namespace lowering { | ||
namespace passes { | ||
|
||
void UnpackRsqrt(std::shared_ptr<torch::jit::Graph>& graph) { | ||
std::string rsqrt_pattern = R"IR( | ||
graph(%1): | ||
%out: Tensor = aten::rsqrt(%1) | ||
return (%out))IR"; | ||
std::string unpacked_pattern = R"IR( | ||
graph(%1): | ||
%intermediate: Tensor = aten::sqrt(%1) | ||
%out: Tensor = aten::reciprocal(%intermediate) | ||
return (%out))IR"; | ||
|
||
torch::jit::SubgraphRewriter rsqrt_rewriter; | ||
rsqrt_rewriter.RegisterRewritePattern(rsqrt_pattern, unpacked_pattern); | ||
rsqrt_rewriter.runOnGraph(graph); | ||
LOG_GRAPH("Post unpack rsqrt: " << *graph); | ||
} | ||
|
||
} // namespace passes | ||
} // namespace lowering | ||
} // namespace core | ||
} // namespace torch_tensorrt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters