Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mul quant #6850

Merged
merged 19 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f1d55df
Merge pull request #1 from PaddlePaddle/develop
newway Dec 16, 2020
12f9e79
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Jul 16, 2021
4c1b79f
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Jul 23, 2021
7ef902e
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Jul 26, 2021
d8a0426
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Jul 27, 2021
2950d7f
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Jul 29, 2021
96bdcbe
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Jul 29, 2021
d7315df
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Jul 30, 2021
08a0257
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Jul 30, 2021
dff74c0
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Aug 11, 2021
4110285
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Sep 3, 2021
b308346
[xpu] support quanted ernie model; test=develop
newway Sep 3, 2021
7c626ea
[XPU] support xpu_kl2_encoder, test=develop, test=xpu
Sep 6, 2021
cfc4d7f
[XPU] refine encoder, test=develop, test=xpu
Sep 13, 2021
273f64d
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Sep 15, 2021
730b077
[XPU] kl2 encoder mask bugfix, test=develop, test=xpu
Sep 15, 2021
8e74020
Merge commit 'refs/pull/6856/head' of https://github.com/PaddlePaddle…
newway Sep 15, 2021
a827668
Merge commit 'refs/pull/6856/head' of https://github.com/PaddlePaddle…
newway Sep 15, 2021
a794b00
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite…
newway Sep 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lite/core/optimizer/mir/fusion/__xpu__fc_fuse_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ class XPUFcFuser : public FuseBase {
} else if (GetStringFromEnv("XPU_ENCODER_PRECISION", "int16") == "int8" ||
lite::TargetWrapperXPU::multi_encoder_precision == "int8") {
precision = "int8";
if (op_desc.HasAttr("enable_int8") &&
op_desc.GetAttr<bool>("enable_int8")) {
CHECK(op_desc.HasAttr("X0_scale")) << " quant model fc no X0_scale";
CHECK(op_desc.HasAttr("Y0_scale")) << " quant model fc no Y0_scale";
VLOG(3) << "Use int8 quant model in XPUFcOp, InputMax:"
<< 127 * op_desc.GetAttr<std::vector<float>>("X0_scale")[0]
<< ", WeightMax: "
<< 127 * op_desc.GetAttr<std::vector<float>>("Y0_scale")[0];
}
VLOG(3) << "Use int8 in XPUFcOp";
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,17 @@ class XPULinkConvMaxFuser : public FuseBase {
public:
explicit XPULinkConvMaxFuser(bool with_branch) { with_branch_ = with_branch; }
void BuildPattern() override {
auto non_quant_teller = [](const Node* node) -> bool {
auto op_desc = *const_cast<Node*>(node)->stmt()->op_info();
return (!op_desc.HasAttr("enable_int8") ||
!op_desc.GetAttr<bool>("enable_int8"));
};

auto* input =
VarNode("input")->assert_is_op_input("__xpu__conv2d", "Input");
auto* xpu_fusion_op =
OpNode("xpu_fusion_op", "__xpu__conv2d")
->assert_node_satisfied(non_quant_teller)
->assert_op_attr<bool>("has_branch", with_branch_);

PMNode* branch = nullptr;
Expand Down Expand Up @@ -100,8 +107,14 @@ class XPULinkConvMaxFuser : public FuseBase {
class XPULinkFcMaxFuser : public FuseBase {
public:
void BuildPattern() override {
auto non_quant_teller = [](const Node* node) -> bool {
auto op_desc = *const_cast<Node*>(node)->stmt()->op_info();
return (!op_desc.HasAttr("enable_int8") ||
!op_desc.GetAttr<bool>("enable_int8"));
};
auto* input = VarNode("input")->assert_is_op_input("__xpu__fc", "Input");
auto* xpu_fusion_op = OpNode("xpu_fusion_op", "__xpu__fc");
auto* xpu_fusion_op = OpNode("xpu_fusion_op", "__xpu__fc")
->assert_node_satisfied(non_quant_teller);

*input >> *xpu_fusion_op;
}
Expand Down
Loading