Skip to content

Commit 353d26c

Browse files
committed
Fix conflicts.
2 parents e845a1d + 76429f4 commit 353d26c

28 files changed

+1450
-98
lines changed

doc/api/v2/fluid/layers.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ dynamic_lstm
1818
.. autofunction:: paddle.v2.fluid.layers.dynamic_lstm
1919
:noindex:
2020

21+
dynamic_gru
22+
-----------
23+
.. autofunction:: paddle.v2.fluid.layers.dynamic_gru
24+
:noindex:
25+
2126
data
2227
----
2328
.. autofunction:: paddle.v2.fluid.layers.data
@@ -500,6 +505,11 @@ swish
500505
.. autofunction:: paddle.v2.fluid.layers.swish
501506
:noindex:
502507

508+
im2sequence
509+
------
510+
.. autofunction:: paddle.v2.fluid.layers.im2sequence
511+
:noindex:
512+
503513
edit_distance
504514
---------------
505515
.. autofunction:: paddle.v2.fluid.layers.edit_distance_error

doc/getstarted/build_and_install/docker_install_cn.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525

2626
.. code-block:: bash
2727
28-
docker pull docker.paddlepaddle.org/paddle
28+
docker pull docker.paddlepaddlehub.com/paddle
2929
3030
下载GPU版本(cuda8.0_cudnn5_avx_mkl)的Docker镜像:
3131

3232
.. code-block:: bash
3333
3434
docker pull paddlepaddle/paddle:latest-gpu
35-
docker pull docker.paddlepaddle.org/paddle:latest-gpu
35+
docker pull docker.paddlepaddlehub.com/paddle:latest-gpu
3636
3737
选择下载使用不同的BLAS库的Docker镜像:
3838

@@ -49,7 +49,7 @@
4949
5050
docker pull paddlepaddle/paddle:[tag]
5151
# 比如:
52-
docker pull docker.paddlepaddle.org/paddle:0.10.0-gpu
52+
docker pull docker.paddlepaddlehub.com/paddle:0.11.0-gpu
5353
5454
.. _docker_run:
5555

doc/getstarted/build_and_install/docker_install_en.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ For users in China, we provide a faster mirror:
2626

2727
.. code-block:: bash
2828
29-
docker pull docker.paddlepaddle.org/paddle
29+
docker pull docker.paddlepaddlehub.com/paddle
3030
3131
Download GPU version (cuda8.0_cudnn5_avx_mkl) images:
3232

3333
.. code-block:: bash
3434
3535
docker pull paddlepaddle/paddle:latest-gpu
36-
docker pull docker.paddlepaddle.org/paddle:latest-gpu
36+
docker pull docker.paddlepaddlehub.com/paddle:latest-gpu
3737
3838
Choose between different BLAS version:
3939

@@ -53,7 +53,7 @@ and run:
5353
5454
docker pull paddlepaddle/paddle:[tag]
5555
# i.e.
56-
docker pull docker.paddlepaddle.org/paddle:0.10.0-gpu
56+
docker pull docker.paddlepaddlehub.com/paddle:0.11.0-gpu
5757
5858
.. _docker_run:
5959

paddle/framework/block_desc.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ std::vector<VarDesc *> BlockDesc::AllVars() const {
7575

7676
OpDesc *BlockDesc::AppendOp() {
7777
need_update_ = true;
78-
ops_.emplace_back(new OpDesc());
78+
ops_.emplace_back(new OpDesc(this));
7979
return ops_.back().get();
8080
}
8181

@@ -86,7 +86,7 @@ void BlockDesc::AppendAllocatedOp(std::unique_ptr<OpDesc> &&op_desc) {
8686

8787
OpDesc *BlockDesc::PrependOp() {
8888
need_update_ = true;
89-
ops_.emplace_front(new OpDesc());
89+
ops_.emplace_front(new OpDesc(this));
9090
return ops_.front().get();
9191
}
9292

@@ -153,7 +153,7 @@ BlockDesc::BlockDesc(ProgramDesc *prog, proto::BlockDesc *desc)
153153
vars_[var_desc.name()].reset(new VarDesc(var_desc));
154154
}
155155
for (const proto::OpDesc &op_desc : desc_->ops()) {
156-
ops_.emplace_back(new OpDesc(op_desc, prog));
156+
ops_.emplace_back(new OpDesc(op_desc, prog, this));
157157
}
158158
}
159159

@@ -162,7 +162,7 @@ BlockDesc::BlockDesc(const BlockDesc &other, proto::BlockDesc *desc,
162162
: prog_(prog), desc_(desc) {
163163
need_update_ = true;
164164
for (auto &op : other.ops_) {
165-
ops_.emplace_back(new OpDesc(*op));
165+
ops_.emplace_back(new OpDesc(*op, this));
166166
}
167167

168168
for (auto &it : other.vars_) {

paddle/framework/op_desc.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void OpDesc::CopyFrom(const OpDesc &op_desc) {
9797
need_update_ = true;
9898
}
9999

100-
OpDesc::OpDesc(const proto::OpDesc &desc, ProgramDesc *prog)
100+
OpDesc::OpDesc(const proto::OpDesc &desc, ProgramDesc *prog, BlockDesc *block)
101101
: desc_(desc), need_update_(false) {
102102
// restore inputs_
103103
int input_size = desc_.inputs_size();
@@ -131,6 +131,7 @@ OpDesc::OpDesc(const proto::OpDesc &desc, ProgramDesc *prog)
131131
attrs_[attr_name] = prog->MutableBlock(bid);
132132
}
133133
}
134+
this->block_ = block;
134135
}
135136

136137
proto::OpDesc *OpDesc::Proto() {

paddle/framework/op_desc.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,21 @@ namespace framework {
2525

2626
class BlockDesc;
2727
class ProgramDesc;
28-
2928
class OpDesc {
3029
public:
3130
OpDesc() {}
3231

3332
OpDesc(const std::string &type, const VariableNameMap &inputs,
3433
const VariableNameMap &outputs, const AttributeMap &attrs);
3534

36-
OpDesc(const proto::OpDesc &desc, ProgramDesc *prog);
35+
OpDesc(const proto::OpDesc &desc, ProgramDesc *prog, BlockDesc *block);
36+
37+
explicit OpDesc(BlockDesc *block) : block_(block) {}
38+
39+
OpDesc(const OpDesc &other, BlockDesc *block) {
40+
*this = other;
41+
block_ = block;
42+
}
3743

3844
void CopyFrom(const OpDesc &op_desc);
3945

@@ -117,6 +123,10 @@ class OpDesc {
117123

118124
void Flush();
119125

126+
BlockDesc *Block() { return this->block_; }
127+
128+
void SetBlock(BlockDesc *block) { this->block_ = block; }
129+
120130
private:
121131
template <typename MapType>
122132
static std::vector<typename MapType::key_type> MapKeys(const MapType &map) {
@@ -129,6 +139,7 @@ class OpDesc {
129139
}
130140

131141
proto::OpDesc desc_;
142+
BlockDesc *block_; // not_own
132143
// input arg name => input variable names
133144
VariableNameMap inputs_;
134145
// output arg name => output variable names

paddle/framework/var_desc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class VarDesc {
6666

6767
std::string Name() const { return desc_.name(); }
6868

69+
void SetName(std::string name) { desc_.set_name(name); }
70+
6971
void SetShape(const std::vector<int64_t> &dims);
7072

7173
void SetDataType(proto::DataType data_type);

paddle/framework/variable_test.cc

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
/*
16-
Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
17-
Licensed under the Apache License, Version 2.0 (the "License");
18-
you may not use this file except in compliance with the License.
19-
You may obtain a copy of the License at
20-
http://www.apache.org/licenses/LICENSE-2.0
21-
Unless required by applicable law or agreed to in writing, software
22-
distributed under the License is distributed on an "AS IS" BASIS,
23-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24-
See the License for the specific language governing permissions and
25-
limitations under the License.
26-
*/
27-
2815
#include <memory>
2916
#include <string>
3017

paddle/operators/iou_similarity_op.cc

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
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/operators/iou_similarity_op.h"
16+
17+
namespace paddle {
18+
namespace operators {
19+
20+
class IOUSimilarityOp : public framework::OperatorWithKernel {
21+
public:
22+
using framework::OperatorWithKernel::OperatorWithKernel;
23+
24+
protected:
25+
void InferShape(framework::InferShapeContext *ctx) const override {
26+
PADDLE_ENFORCE(ctx->HasInput("X"),
27+
"Input(X) of IOUSimilarityOp should not be null.");
28+
PADDLE_ENFORCE(ctx->HasInput("Y"),
29+
"Input(Y) of IOUSimilarityOp should not be null.");
30+
auto x_dims = ctx->GetInputDim("X");
31+
auto y_dims = ctx->GetInputDim("Y");
32+
33+
PADDLE_ENFORCE_EQ(x_dims.size(), 2UL, "The rank of Input(X) must be 2.");
34+
PADDLE_ENFORCE_EQ(x_dims[1], 4UL, "The shape of X is [N, 4]");
35+
PADDLE_ENFORCE_EQ(y_dims.size(), 2UL, "The rank of Input(Y) must be 2.");
36+
PADDLE_ENFORCE_EQ(y_dims[1], 4UL, "The shape of Y is [M, 4]");
37+
38+
ctx->ShareLoD("X", /*->*/ "Out");
39+
ctx->SetOutputDim("Out", framework::make_ddim({x_dims[0], y_dims[0]}));
40+
}
41+
};
42+
43+
class IOUSimilarityOpMaker : public framework::OpProtoAndCheckerMaker {
44+
public:
45+
IOUSimilarityOpMaker(OpProto *proto, OpAttrChecker *op_checker)
46+
: OpProtoAndCheckerMaker(proto, op_checker) {
47+
AddInput("X",
48+
"(LoDTensor, default LoDTensor<float>) "
49+
"Box list X is a 2-D LoDTensor with shape [N, 4] holds N boxes, "
50+
"each box is represented as [xmin, ymin, xmax, ymax], "
51+
"the shape of X is [N, 4]. [xmin, ymin] is the left top "
52+
"coordinate of the box if the input is image feature map, they "
53+
"are close to the origin of the coordinate system. "
54+
"[xmax, ymax] is the right bottom coordinate of the box. "
55+
"This tensor can contain LoD information to represent a batch "
56+
"of inputs. One instance of this batch can contain different "
57+
"numbers of entities.");
58+
AddInput("Y",
59+
"(Tensor, default Tensor<float>) "
60+
"Box list Y holds M boxes, each box is represented as "
61+
"[xmin, ymin, xmax, ymax], the shape of X is [N, 4]. "
62+
"[xmin, ymin] is the left top coordinate of the box if the "
63+
"input is image feature map, and [xmax, ymax] is the right "
64+
"bottom coordinate of the box.");
65+
66+
AddOutput("Out",
67+
"(LoDTensor, the lod is same as input X) The output of "
68+
"iou_similarity op, a tensor with shape [N, M] "
69+
"representing pairwise iou scores.");
70+
71+
AddComment(R"DOC(
72+
IOU Similarity Operator.
73+
Computes intersection-over-union (IOU) between two box lists.
74+
Box list 'X' should be a LoDTensor and 'Y' is a common Tensor,
75+
boxes in 'Y' are shared by all instance of the batched inputs of X.
76+
Given two boxes A and B, the calculation of IOU is as follows:
77+
78+
$$
79+
IOU(A, B) =
80+
\frac{area(A\cap B)}{area(A)+area(B)-area(A\cap B)}
81+
$$
82+
83+
)DOC");
84+
}
85+
};
86+
} // namespace operators
87+
} // namespace paddle
88+
89+
namespace ops = paddle::operators;
90+
REGISTER_OP_WITHOUT_GRADIENT(iou_similarity, ops::IOUSimilarityOp,
91+
ops::IOUSimilarityOpMaker);
92+
93+
REGISTER_OP_CPU_KERNEL(
94+
iou_similarity,
95+
ops::IOUSimilarityKernel<paddle::platform::CPUDeviceContext, float>,
96+
ops::IOUSimilarityKernel<paddle::platform::CPUDeviceContext, double>);

paddle/operators/iou_similarity_op.cu

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
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/operators/iou_similarity_op.h"
16+
17+
namespace ops = paddle::operators;
18+
REGISTER_OP_CUDA_KERNEL(
19+
iou_similarity,
20+
ops::IOUSimilarityKernel<paddle::platform::CUDADeviceContext, float>,
21+
ops::IOUSimilarityKernel<paddle::platform::CUDADeviceContext, double>);

0 commit comments

Comments
 (0)