未验证 提交 096eb801 编写于 作者: L lidanqing 提交者: GitHub

remove slowing down pass (#43750)

上级 9d12e70c
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <miopen/miopen.h> #include <miopen/miopen.h>
#endif #endif
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
#include <sstream> #include <sstream>
namespace paddle { namespace paddle {
...@@ -60,6 +61,12 @@ void PaddlePassBuilder::DeletePass(const std::string &pass_type) { ...@@ -60,6 +61,12 @@ void PaddlePassBuilder::DeletePass(const std::string &pass_type) {
} }
} }
size_t PaddlePassBuilder::GetPassIndex(const std::string &pass_type) {
auto iter = std::find(std::begin(passes_), std::end(passes_), pass_type);
if (iter == std::end(passes_)) return -1;
return std::distance(std::begin(passes_), iter);
}
void PaddlePassBuilder::InsertPass(size_t idx, const std::string &pass_type) { void PaddlePassBuilder::InsertPass(size_t idx, const std::string &pass_type) {
passes_.insert(std::begin(passes_) + idx, pass_type); passes_.insert(std::begin(passes_) + idx, pass_type);
} }
...@@ -268,7 +275,11 @@ void CpuPassStrategy::EnableMKLDNN() { ...@@ -268,7 +275,11 @@ void CpuPassStrategy::EnableMKLDNN() {
#ifdef PADDLE_WITH_MKLDNN #ifdef PADDLE_WITH_MKLDNN
if (!use_mkldnn_) { if (!use_mkldnn_) {
passes_.insert(passes_.begin(), "mkldnn_placement_pass"); passes_.insert(passes_.begin(), "mkldnn_placement_pass");
int id = GetPassIndex("gpu_cpu_reshape2_matmul_fuse_pass");
// this pass slows down FC mkldnn int8 operator
if (id != -1) {
passes_.erase(passes_.begin() + id);
}
for (auto &pass : std::vector<std::string>({ for (auto &pass : std::vector<std::string>({
"depthwise_conv_mkldnn_pass", // "depthwise_conv_mkldnn_pass", //
"conv_bn_fuse_pass", // Execute BN passes again to "conv_bn_fuse_pass", // Execute BN passes again to
......
...@@ -75,6 +75,10 @@ class PD_INFER_DECL PaddlePassBuilder { ...@@ -75,6 +75,10 @@ class PD_INFER_DECL PaddlePassBuilder {
/// \param[in] pass_type the certain pass type to be deleted. /// \param[in] pass_type the certain pass type to be deleted.
void DeletePass(const std::string &pass_type); void DeletePass(const std::string &pass_type);
/// \brief Get the certain position of a pass.
// \param[in] pass_type the type of insert pass.
size_t GetPassIndex(const std::string &pass_type);
/// \brief Delete all the passes. /// \brief Delete all the passes.
void ClearPasses(); void ClearPasses();
......
...@@ -411,7 +411,7 @@ class Quant2Int8MkldnnPass(object): ...@@ -411,7 +411,7 @@ class Quant2Int8MkldnnPass(object):
graph = self._apply_pass(graph, 'multi_gru_seq_fuse_pass') graph = self._apply_pass(graph, 'multi_gru_seq_fuse_pass')
graph = self._apply_pass(graph, 'seq_concat_fc_fuse_pass') graph = self._apply_pass(graph, 'seq_concat_fc_fuse_pass')
graph = self._apply_pass(graph, 'gpu_cpu_squeeze2_matmul_fuse_pass') graph = self._apply_pass(graph, 'gpu_cpu_squeeze2_matmul_fuse_pass')
graph = self._apply_pass(graph, 'gpu_cpu_reshape2_matmul_fuse_pass') #graph = self._apply_pass(graph, 'gpu_cpu_reshape2_matmul_fuse_pass')
graph = self._apply_pass(graph, 'gpu_cpu_flatten2_matmul_fuse_pass') graph = self._apply_pass(graph, 'gpu_cpu_flatten2_matmul_fuse_pass')
graph = self._apply_pass(graph, 'matmul_v2_scale_fuse_pass') graph = self._apply_pass(graph, 'matmul_v2_scale_fuse_pass')
graph = self._apply_pass(graph, 'squared_mat_sub_fuse_pass') graph = self._apply_pass(graph, 'squared_mat_sub_fuse_pass')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册