Skip to content

Commit 6c1d74b

Browse files
committed
Merge branch 'develop' into FasterOpDoc
test=develop
2 parents d0ccdf8 + 5ffb48d commit 6c1d74b

File tree

142 files changed

+7856
-1652
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+7856
-1652
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33

44
[![Build Status](https://travis-ci.org/PaddlePaddle/Paddle.svg?branch=develop)](https://travis-ci.org/PaddlePaddle/Paddle)
5-
[![Documentation Status](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](http://www.paddlepaddle.org/docs/develop/documentation/en/getstarted/index_en.html)
6-
[![Documentation Status](https://img.shields.io/badge/中文文档-最新-brightgreen.svg)](http://www.paddlepaddle.org/docs/develop/documentation/zh/getstarted/index_cn.html)
5+
[![Documentation Status](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](http://paddlepaddle.org/documentation/docs/en/1.0/getstarted/index_en.html)
6+
[![Documentation Status](https://img.shields.io/badge/中文文档-最新-brightgreen.svg)](http://paddlepaddle.org/documentation/docs/zh/1.0/beginners_guide/index.html)
77
[![Release](https://img.shields.io/github/release/PaddlePaddle/Paddle.svg)](https://github.com/PaddlePaddle/Paddle/releases)
88
[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE)
99

@@ -19,17 +19,17 @@ Our vision is to enable deep learning for everyone via PaddlePaddle.
1919
Please refer to our [release announcement](https://github.com/PaddlePaddle/Paddle/releases) to track the latest feature of PaddlePaddle.
2020

2121

22-
### Latest PaddlePaddle Release: [Fluid 1.0.0](https://github.com/PaddlePaddle/Paddle/tree/release/1.0.0)
22+
### Latest PaddlePaddle Release: [Fluid 1.0.1](https://github.com/PaddlePaddle/Paddle/tree/release/1.0.0)
2323
### Install Latest Stable Release:
2424
```
2525
# Linux CPU
2626
pip install paddlepaddle
2727
# Linux GPU cuda9cudnn7
2828
pip install paddlepaddle-gpu
2929
# Linux GPU cuda8cudnn7
30-
pip install paddlepaddle-gpu==0.15.0.post87
30+
pip install paddlepaddle-gpu==1.0.1.post87
3131
# Linux GPU cuda8cudnn5
32-
pip install paddlepaddle-gpu==0.15.0.post85
32+
pip install paddlepaddle-gpu==1.0.1.post85
3333
3434
# For installation on other platform, refer to http://paddlepaddle.org/
3535
```

cmake/generic.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,13 @@ function(cc_library TARGET_NAME)
261261
add_dependencies(${TARGET_NAME} mklml)
262262
target_link_libraries(${TARGET_NAME} "-L${MKLML_LIB_DIR} -liomp5 -Wl,--as-needed")
263263
endif()
264+
# remove link to python, see notes at:
265+
# https://github.com/pybind/pybind11/blob/master/docs/compiling.rst#building-manually
266+
if("${cc_library_DEPS};" MATCHES "python;")
267+
list(REMOVE_ITEM cc_library_DEPS python)
268+
add_dependencies(${TARGET_NAME} python)
269+
target_link_libraries(${TARGET_NAME} "-Wl,-undefined,dynamic_lookup")
270+
endif()
264271
target_link_libraries(${TARGET_NAME} ${cc_library_DEPS})
265272
add_dependencies(${TARGET_NAME} ${cc_library_DEPS})
266273
endif()
@@ -311,6 +318,8 @@ function(cc_test TARGET_NAME)
311318
set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_cpu_deterministic=true)
312319
set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_init_allocated_mem=true)
313320
set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_cudnn_deterministic=true)
321+
# No unit test should exceed 10 minutes.
322+
set_tests_properties(${TARGET_NAME} PROPERTIES TIMEOUT 600)
314323
endif()
315324
endfunction(cc_test)
316325

@@ -629,6 +638,8 @@ function(py_test TARGET_NAME)
629638
PYTHONPATH=${PADDLE_BINARY_DIR}/python ${py_test_ENVS}
630639
${PYTHON_EXECUTABLE} -u ${py_test_SRCS} ${py_test_ARGS}
631640
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
641+
# No unit test should exceed 10 minutes.
642+
set_tests_properties(${TARGET_NAME} PROPERTIES TIMEOUT 600)
632643
endif()
633644
endfunction()
634645

paddle/fluid/API.spec

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ paddle.fluid.layers.cos_sim ArgSpec(args=['X', 'Y'], varargs=None, keywords=None
6161
paddle.fluid.layers.cross_entropy ArgSpec(args=['input', 'label', 'soft_label', 'ignore_index'], varargs=None, keywords=None, defaults=(False, -100))
6262
paddle.fluid.layers.square_error_cost ArgSpec(args=['input', 'label'], varargs=None, keywords=None, defaults=None)
6363
paddle.fluid.layers.chunk_eval ArgSpec(args=['input', 'label', 'chunk_scheme', 'num_chunk_types', 'excluded_chunk_types'], varargs=None, keywords=None, defaults=(None,))
64-
paddle.fluid.layers.sequence_conv ArgSpec(args=['input', 'num_filters', 'filter_size', 'filter_stride', 'padding', 'bias_attr', 'param_attr', 'act'], varargs=None, keywords=None, defaults=(3, 1, None, None, None, None))
64+
paddle.fluid.layers.sequence_conv ArgSpec(args=['input', 'num_filters', 'filter_size', 'filter_stride', 'padding', 'bias_attr', 'param_attr', 'act', 'name'], varargs=None, keywords=None, defaults=(3, 1, None, None, None, None, None))
6565
paddle.fluid.layers.conv2d ArgSpec(args=['input', 'num_filters', 'filter_size', 'stride', 'padding', 'dilation', 'groups', 'param_attr', 'bias_attr', 'use_cudnn', 'act', 'name'], varargs=None, keywords=None, defaults=(1, 0, 1, None, None, None, True, None, None))
6666
paddle.fluid.layers.conv3d ArgSpec(args=['input', 'num_filters', 'filter_size', 'stride', 'padding', 'dilation', 'groups', 'param_attr', 'bias_attr', 'use_cudnn', 'act', 'name'], varargs=None, keywords=None, defaults=(1, 0, 1, None, None, None, True, None, None))
6767
paddle.fluid.layers.sequence_pool ArgSpec(args=['input', 'pool_type'], varargs=None, keywords=None, defaults=None)
68-
paddle.fluid.layers.sequence_softmax ArgSpec(args=['input', 'param_attr', 'bias_attr', 'use_cudnn'], varargs=None, keywords=None, defaults=(None, None, False))
69-
paddle.fluid.layers.softmax ArgSpec(args=['input', 'param_attr', 'bias_attr', 'use_cudnn', 'name'], varargs=None, keywords=None, defaults=(None, None, True, None))
68+
paddle.fluid.layers.sequence_softmax ArgSpec(args=['input', 'use_cudnn', 'name'], varargs=None, keywords=None, defaults=(False, None))
69+
paddle.fluid.layers.softmax ArgSpec(args=['input', 'use_cudnn', 'name'], varargs=None, keywords=None, defaults=(True, None))
7070
paddle.fluid.layers.pool2d ArgSpec(args=['input', 'pool_size', 'pool_type', 'pool_stride', 'pool_padding', 'global_pooling', 'use_cudnn', 'ceil_mode', 'name'], varargs=None, keywords=None, defaults=(-1, 'max', 1, 0, False, True, False, None))
7171
paddle.fluid.layers.pool3d ArgSpec(args=['input', 'pool_size', 'pool_type', 'pool_stride', 'pool_padding', 'global_pooling', 'use_cudnn', 'ceil_mode', 'name'], varargs=None, keywords=None, defaults=(-1, 'max', 1, 0, False, True, False, None))
7272
paddle.fluid.layers.batch_norm ArgSpec(args=['input', 'act', 'is_test', 'momentum', 'epsilon', 'param_attr', 'bias_attr', 'data_layout', 'in_place', 'name', 'moving_mean_name', 'moving_variance_name', 'do_model_average_for_mean_and_var', 'fuse_with_relu'], varargs=None, keywords=None, defaults=(None, False, 0.9, 1e-05, None, None, 'NCHW', False, None, None, None, False, False))
@@ -97,8 +97,8 @@ paddle.fluid.layers.warpctc ArgSpec(args=['input', 'label', 'blank', 'norm_by_ti
9797
paddle.fluid.layers.sequence_reshape ArgSpec(args=['input', 'new_dim'], varargs=None, keywords=None, defaults=None)
9898
paddle.fluid.layers.transpose ArgSpec(args=['x', 'perm', 'name'], varargs=None, keywords=None, defaults=(None,))
9999
paddle.fluid.layers.im2sequence ArgSpec(args=['input', 'filter_size', 'stride', 'padding', 'input_image_size', 'out_stride', 'name'], varargs=None, keywords=None, defaults=(1, 1, 0, None, 1, None))
100-
paddle.fluid.layers.nce ArgSpec(args=['input', 'label', 'num_total_classes', 'sample_weight', 'param_attr', 'bias_attr', 'num_neg_samples'], varargs=None, keywords=None, defaults=(None, None, None, None))
101-
paddle.fluid.layers.hsigmoid ArgSpec(args=['input', 'label', 'num_classes', 'param_attr', 'bias_attr'], varargs=None, keywords=None, defaults=(None, None))
100+
paddle.fluid.layers.nce ArgSpec(args=['input', 'label', 'num_total_classes', 'sample_weight', 'param_attr', 'bias_attr', 'num_neg_samples', 'name'], varargs=None, keywords=None, defaults=(None, None, None, None, None))
101+
paddle.fluid.layers.hsigmoid ArgSpec(args=['input', 'label', 'num_classes', 'param_attr', 'bias_attr', 'name'], varargs=None, keywords=None, defaults=(None, None, None))
102102
paddle.fluid.layers.beam_search ArgSpec(args=['pre_ids', 'pre_scores', 'ids', 'scores', 'beam_size', 'end_id', 'level', 'name'], varargs=None, keywords=None, defaults=(0, None))
103103
paddle.fluid.layers.row_conv ArgSpec(args=['input', 'future_context_size', 'param_attr', 'act'], varargs=None, keywords=None, defaults=(None, None))
104104
paddle.fluid.layers.multiplex ArgSpec(args=['inputs', 'index'], varargs=None, keywords=None, defaults=None)
@@ -116,6 +116,7 @@ paddle.fluid.layers.pad ArgSpec(args=['x', 'paddings', 'pad_value', 'name'], var
116116
paddle.fluid.layers.pad_constant_like ArgSpec(args=['x', 'y', 'pad_value', 'name'], varargs=None, keywords=None, defaults=(0.0, None))
117117
paddle.fluid.layers.label_smooth ArgSpec(args=['label', 'prior_dist', 'epsilon', 'dtype', 'name'], varargs=None, keywords=None, defaults=(None, 0.1, 'float32', None))
118118
paddle.fluid.layers.roi_pool ArgSpec(args=['input', 'rois', 'pooled_height', 'pooled_width', 'spatial_scale'], varargs=None, keywords=None, defaults=(1, 1, 1.0))
119+
paddle.fluid.layers.roi_align ArgSpec(args=['input', 'rois', 'pooled_height', 'pooled_width', 'spatial_scale', 'sampling_ratio', 'name'], varargs=None, keywords=None, defaults=(1, 1, 1.0, -1, None))
119120
paddle.fluid.layers.dice_loss ArgSpec(args=['input', 'label', 'epsilon'], varargs=None, keywords=None, defaults=(1e-05,))
120121
paddle.fluid.layers.image_resize ArgSpec(args=['input', 'out_shape', 'scale', 'name', 'resample'], varargs=None, keywords=None, defaults=(None, None, None, 'BILINEAR'))
121122
paddle.fluid.layers.image_resize_short ArgSpec(args=['input', 'out_short_len', 'resample'], varargs=None, keywords=None, defaults=('BILINEAR',))

paddle/fluid/framework/details/var_handle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ struct VarHandleBase {
4949

5050
void AddOutput(OpHandleBase* out, ir::Node* node) {
5151
if (pending_ops_.find(out) == pending_ops_.end()) {
52+
PADDLE_ENFORCE(out != nullptr, "The output of %s should not be nullptr",
53+
this->Node()->Name());
5254
pending_ops_.insert(out);
5355
node_->outputs.push_back(node);
5456
}

paddle/fluid/framework/framework.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ message OpProto {
8080
optional bool duplicable = 3 [ default = false ];
8181
optional bool intermediate = 4 [ default = false ];
8282
optional bool dispensable = 5 [ default = false ];
83-
optional string reuse = 6;
8483
}
8584

8685
// AttrProto describes the C++ type Attribute.

paddle/fluid/framework/ir/CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function(pass_library TARGET DEST)
1010
set(oneValueArgs "")
1111
set(multiValueArgs SRCS DEPS)
1212
cmake_parse_arguments(op_library "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
13-
cc_library(${TARGET} SRCS ${TARGET}.cc DEPS graph_pattern_detector pass ${op_library_DEPS})
13+
cc_library(${TARGET} SRCS ${TARGET}.cc DEPS graph_pattern_detector pass fuse_pass_base ${op_library_DEPS})
1414
# add more DEST here, such as train, dist and collect USE_PASS into a file automatically.
1515
if (${DEST} STREQUAL "base" OR ${DEST} STREQUAL "inference")
1616
message(STATUS "add pass ${TARGET} ${DEST}")
@@ -25,20 +25,25 @@ cc_library(graph_helper SRCS graph_helper.cc DEPS graph)
2525
cc_library(pass SRCS pass.cc DEPS graph node graph_helper)
2626
cc_library(graph_traits SRCS graph_traits.cc DEPS graph)
2727
cc_library(graph_pattern_detector SRCS graph_pattern_detector.cc DEPS graph graph_helper graph_traits)
28+
cc_library(fuse_pass_base SRCS fuse_pass_base.cc DEPS pass)
2829

2930
pass_library(graph_to_program_pass base)
3031
pass_library(graph_viz_pass base)
3132
pass_library(fc_fuse_pass inference)
32-
if (WITH_MKLDNN)
33-
pass_library(conv_relu_mkldnn_fuse_pass inference)
34-
endif ()
3533
pass_library(attention_lstm_fuse_pass inference)
3634
pass_library(infer_clean_graph_pass inference)
3735
pass_library(fc_lstm_fuse_pass inference)
3836
pass_library(embedding_fc_lstm_fuse_pass inference)
3937
pass_library(fc_gru_fuse_pass inference)
4038
pass_library(seq_concat_fc_fuse_pass inference)
4139
pass_library(conv_bn_fuse_pass inference)
40+
pass_library(seqconv_eltadd_relu_fuse_pass inference)
41+
if(WITH_MKLDNN)
42+
pass_library(mkldnn_placement_pass base)
43+
pass_library(conv_bias_mkldnn_fuse_pass inference)
44+
pass_library(conv_relu_mkldnn_fuse_pass inference)
45+
pass_library(conv_elementwise_add_mkldnn_fuse_pass inference)
46+
endif()
4247

4348
cc_library(fuse_elewise_add_act_pass SRCS fuse_elewise_add_act_pass.cc DEPS pass graph_pattern_detector )
4449

@@ -54,4 +59,5 @@ cc_test(test_graph_pattern_detector SRCS graph_pattern_detector_tester.cc DEPS g
5459
cc_test(test_fc_fuse_pass SRCS fc_fuse_pass_tester.cc DEPS fc_fuse_pass framework_proto)
5560
if (WITH_MKLDNN)
5661
cc_test(test_conv_relu_mkldnn_fuse_pass SRCS conv_relu_mkldnn_fuse_pass_tester.cc DEPS conv_relu_mkldnn_fuse_pass)
62+
cc_test(test_conv_elementwise_add_mkldnn_fuse_pass SRCS conv_elementwise_add_mkldnn_fuse_pass_tester.cc DEPS conv_elementwise_add_mkldnn_fuse_pass)
5763
endif ()

paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ std::unique_ptr<ir::Graph> AttentionLSTMFusePass::ApplyImpl(
262262
std::unordered_set<std::string> specified_vars({"data_lod_attention",
263263
"cell_init", "hidden_init",
264264
"data", "week", "minute"});
265-
int count = 0;
265+
size_t count = 0;
266266
for (auto* node : graph->Nodes()) {
267267
if (node->IsVar() && specified_vars.count(node->Name())) {
268268
++count;
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "paddle/fluid/framework/ir/conv_bias_mkldnn_fuse_pass.h"
16+
#include <functional>
17+
#include <string>
18+
#include <vector>
19+
#include "paddle/fluid/framework/lod_tensor.h"
20+
#include "paddle/fluid/platform/enforce.h"
21+
22+
namespace paddle {
23+
namespace framework {
24+
namespace ir {
25+
26+
template <typename BinaryOperation>
27+
LoDTensor tensor_apply_eltwise(const LoDTensor& vec_a, const LoDTensor& vec_b,
28+
BinaryOperation f) {
29+
PADDLE_ENFORCE_EQ(vec_a.dims(), vec_b.dims());
30+
LoDTensor vec_y;
31+
vec_y.Resize(vec_a.dims());
32+
const float* a = vec_a.data<float>();
33+
const float* b = vec_b.data<float>();
34+
float* y = vec_y.mutable_data<float>(platform::CPUPlace());
35+
for (int i = 0; i < vec_a.numel(); i++) {
36+
y[i] = f(a[i], b[i]);
37+
}
38+
return vec_y;
39+
}
40+
41+
std::unique_ptr<ir::Graph> ConvBiasFusePass::ApplyImpl(
42+
std::unique_ptr<ir::Graph> graph) const {
43+
PADDLE_ENFORCE(graph.get());
44+
FusePassBase::Init(name_scope_, graph.get());
45+
46+
auto* scope = param_scope();
47+
PADDLE_ENFORCE(scope);
48+
49+
GraphPatternDetector gpd;
50+
auto* conv_input =
51+
gpd.mutable_pattern()
52+
->NewNode(patterns::PDNodeName(name_scope_, "conv_input"))
53+
->AsInput()
54+
->assert_is_op_input("conv2d", "Input");
55+
patterns::ConvBias conv_bias_pattern(gpd.mutable_pattern(), name_scope_);
56+
conv_bias_pattern(conv_input);
57+
int found_conv_bias_count = 0;
58+
auto handler = [&](const GraphPatternDetector::subgraph_t& subgraph,
59+
Graph* g) {
60+
VLOG(4) << "handle ConvBias fuse";
61+
GET_IR_NODE_FROM_SUBGRAPH(conv_weight, conv_weight,
62+
conv_bias_pattern); // Filter
63+
GET_IR_NODE_FROM_SUBGRAPH(conv_out, conv_out, conv_bias_pattern); // tmp
64+
GET_IR_NODE_FROM_SUBGRAPH(conv, conv, conv_bias_pattern); // CONV op
65+
// bias
66+
GET_IR_NODE_FROM_SUBGRAPH(eltwise_bias, eltwise_bias, conv_bias_pattern);
67+
// output
68+
GET_IR_NODE_FROM_SUBGRAPH(eltwise_out, eltwise_out, conv_bias_pattern);
69+
// elementwise_add op
70+
GET_IR_NODE_FROM_SUBGRAPH(eltwise, eltwise, conv_bias_pattern);
71+
72+
PADDLE_ENFORCE(subgraph.count(conv_input));
73+
74+
// check if fuse can be done and if MKL-DNN should be used
75+
FuseOptions fuse_option = FindFuseOption(*conv, *eltwise);
76+
if (fuse_option == DO_NOT_FUSE || fuse_option == FUSE_NATIVE) {
77+
VLOG(3) << "do not perform conv+bias fuse";
78+
return;
79+
}
80+
81+
auto* eltwise_bias_tensor =
82+
scope->FindVar(eltwise_bias->Name())->GetMutable<LoDTensor>();
83+
84+
auto input_names = conv->Op()->InputNames();
85+
bool has_bias = std::find(input_names.begin(), input_names.end(), "Bias") !=
86+
input_names.end();
87+
if (has_bias && conv->Op()->Input("Bias").size() > 0) {
88+
auto conv_bias_names = conv->Op()->Input("Bias");
89+
// add eltwise bias to existing conv bias
90+
PADDLE_ENFORCE_EQ(conv_bias_names.size(), 1);
91+
auto* conv_bias_var = scope->FindVar(conv_bias_names[0]);
92+
auto* conv_bias_tensor = conv_bias_var->GetMutable<LoDTensor>();
93+
PADDLE_ENFORCE_EQ(conv_bias_tensor->dims(), eltwise_bias_tensor->dims());
94+
*conv_bias_tensor = tensor_apply_eltwise(
95+
*conv_bias_tensor, *eltwise_bias_tensor, std::plus<float>());
96+
97+
conv->Op()->SetOutput("Output",
98+
std::vector<std::string>({eltwise_out->Name()}));
99+
100+
GraphSafeRemoveNodes(graph.get(), {eltwise, conv_out});
101+
102+
IR_NODE_LINK_TO(conv, eltwise_out);
103+
} else {
104+
// take eltwise bias as conv bias
105+
OpDesc desc;
106+
107+
desc.SetInput(
108+
"Input", std::vector<std::string>({subgraph.at(conv_input)->Name()}));
109+
desc.SetInput("Filter", std::vector<std::string>({conv_weight->Name()}));
110+
desc.SetInput("Bias", std::vector<std::string>({eltwise_bias->Name()}));
111+
desc.SetOutput("Output", std::vector<std::string>({eltwise_out->Name()}));
112+
desc.SetType("conv2d");
113+
114+
for (auto& attr : conv->Op()->GetAttrMap()) {
115+
desc.SetAttr(attr.first, attr.second);
116+
}
117+
auto conv_bias_node = g->CreateOpNode(&desc);
118+
119+
IR_NODE_LINK_TO(subgraph.at(conv_input), conv_bias_node);
120+
IR_NODE_LINK_TO(conv_weight, conv_bias_node);
121+
IR_NODE_LINK_TO(eltwise_bias, conv_bias_node);
122+
IR_NODE_LINK_TO(conv_bias_node, eltwise_out);
123+
124+
GraphSafeRemoveNodes(graph.get(), {conv, eltwise, conv_out});
125+
}
126+
127+
found_conv_bias_count++;
128+
};
129+
gpd(graph.get(), handler);
130+
AddStatis(found_conv_bias_count);
131+
return graph;
132+
}
133+
} // namespace ir
134+
} // namespace framework
135+
} // namespace paddle
136+
REGISTER_PASS(conv_bias_mkldnn_fuse_pass,
137+
paddle::framework::ir::ConvBiasFusePass);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
#pragma once
15+
#include <string>
16+
#include "paddle/fluid/framework/ir/fuse_pass_base.h"
17+
#include "paddle/fluid/framework/ir/graph.h"
18+
#include "paddle/fluid/framework/ir/graph_pattern_detector.h"
19+
#include "paddle/fluid/framework/ir/pass.h"
20+
namespace paddle {
21+
namespace framework {
22+
namespace ir {
23+
/*
24+
* Fuse the Conv and Elementwise_add to a ConvBiasOp.
25+
*/
26+
class ConvBiasFusePass : public FusePassBase {
27+
public:
28+
virtual ~ConvBiasFusePass() {}
29+
30+
protected:
31+
std::unique_ptr<ir::Graph> ApplyImpl(std::unique_ptr<ir::Graph> graph) const;
32+
const std::string name_scope_{"conv_bias_mkldnn_fuse"};
33+
};
34+
} // namespace ir
35+
} // namespace framework
36+
} // namespace paddle

0 commit comments

Comments
 (0)