-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(aten::linear): Fixes new issues in 1.8 that cause script based
models to fail while trace models work. Seems to be down to the fact that the two create different graphs and script was having issues with aten::linear Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
- Loading branch information
1 parent
71c4dcb
commit c5057f8
Showing
9 changed files
with
76 additions
and
22 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
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,34 @@ | ||
#include <string> | ||
#include "core/compiler.h" | ||
#include "core/lowering/passes/passes.h" | ||
#include "gtest/gtest.h" | ||
#include "tests/util/util.h" | ||
#include "torch/csrc/jit/ir/irparser.h" | ||
#include "torch/csrc/jit/ir/subgraph_matcher.h" | ||
|
||
TEST(LoweringPasses, LinearToAddMM) { | ||
std::string source_graph = R"IR( | ||
graph(%input, %6, %7, %weight, %bias): | ||
%flat = aten::flatten(%input, %6, %7) | ||
%res = aten::linear(%flat, %weight, %bias) | ||
return (%res))IR"; | ||
std::string target_graph = R"IR( | ||
graph(%input, %6, %7, %weight_t, %bias): | ||
%1: int = prim::Constant[value=1]() | ||
%flat = aten::flatten(%input, %6, %7) | ||
%weight = aten::t(%weight_t) | ||
%mm: Tensor = aten::matmul(%flat, %weight) | ||
%b_f: Tensor = trt::const(%bias) | ||
%out: Tensor = aten::add_(%b_f, %mm, %1) | ||
return (%out))IR"; | ||
|
||
trtorch::core::util::logging::get_logger().set_reportable_log_level(trtorch::core::util::logging::LogLevel::kGRAPH); | ||
auto sg = std::make_shared<torch::jit::Graph>(); | ||
torch::jit::parseIR(source_graph, &*sg); | ||
trtorch::core::lowering::passes::LinearToAddMM(sg); | ||
|
||
auto tg = std::make_shared<torch::jit::Graph>(); | ||
torch::jit::parseIR(target_graph, &*tg); | ||
|
||
ASSERT_TRUE(!torch::jit::findPatternMatches(*tg, *sg).empty()); | ||
} |
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