Skip to content

Commit 7b71976

Browse files
committed
Merge branch 'develop' into api
2 parents e725ae7 + f9f8fba commit 7b71976

File tree

6 files changed

+511
-17
lines changed

6 files changed

+511
-17
lines changed

paddle/fluid/API.spec

Lines changed: 438 additions & 0 deletions
Large diffs are not rendered by default.

paddle/fluid/operators/im2sequence_op.cc

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,14 @@ class Im2SequenceOp : public framework::OperatorWithKernel {
3333

3434
PADDLE_ENFORCE_EQ(in_dim.size(), 4,
3535
"Input(X) format must be 4D tensor, eg., NCHW.");
36-
int batch_size = in_dim[0];
3736
int img_channels = in_dim[1];
38-
int img_height = in_dim[2];
39-
int img_width = in_dim[3];
4037

4138
auto kernels = ctx->Attrs().Get<std::vector<int>>("kernels");
4239
auto strides = ctx->Attrs().Get<std::vector<int>>("strides");
4340
auto paddings = ctx->Attrs().Get<std::vector<int>>("paddings");
4441

45-
int output_height = Im2SeqOutputSize(img_height, kernels[0], paddings[0],
46-
paddings[2], strides[0]);
47-
int output_width = Im2SeqOutputSize(img_width, kernels[1], paddings[1],
48-
paddings[3], strides[1]);
49-
50-
ctx->SetOutputDim("Out", {batch_size * output_height * output_width,
51-
img_channels * kernels[0] * kernels[1]});
42+
ctx->SetOutputDim("Out",
43+
{in_dim[0], img_channels * kernels[0] * kernels[1]});
5244
}
5345
};
5446

paddle/fluid/operators/im2sequence_op.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,13 @@ class Im2SequenceKernel : public framework::OpKernel<T> {
109109
}
110110
out->set_lod(lod);
111111
} else {
112-
out->mutable_data<T>(ctx.GetPlace());
113112
int output_height = Im2SeqOutputSize(img_height, kernels[0], paddings[0],
114113
paddings[2], strides[0]);
115114
int output_width = Im2SeqOutputSize(img_width, kernels[1], paddings[1],
116115
paddings[3], strides[1]);
117-
116+
out->mutable_data<T>({batch_size * output_height * output_width,
117+
img_channels * kernels[0] * kernels[1]},
118+
ctx.GetPlace());
118119
const std::vector<int> dilations({1, 1});
119120
auto out_dims = out->dims();
120121
out->Resize({batch_size, out->numel() / batch_size});

paddle/fluid/operators/sum_mkldnn_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class SumMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
8888
input_format = memory::format::nc;
8989
}
9090

91-
for (int i = in_place ? 1 : 0; i < N; i++) {
91+
for (int i = 0; i < N; i++) {
9292
PADDLE_ENFORCE(in_vars[i]->IsType<LoDTensor>(),
9393
"all inputs must be all LoDTensors");
9494
auto& input = in_vars[i]->Get<LoDTensor>();

paddle/scripts/paddle_build.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# Utils
2020
#=================================================
2121

22+
set -ex
23+
2224
function print_usage() {
2325
echo -e "\n${RED}Usage${NONE}:
2426
${BOLD}${SCRIPT_NAME}${NONE} [OPTION]"
@@ -37,6 +39,7 @@ function print_usage() {
3739
${BLUE}fluid_inference_lib${NONE}: deploy fluid inference library
3840
${BLUE}check_style${NONE}: run code style check
3941
${BLUE}cicheck${NONE}: run CI tasks
42+
${BLUE}assert_api_not_changed${NONE}: check api compability
4043
"
4144
}
4245

@@ -326,11 +329,23 @@ function assert_api_not_changed() {
326329
virtualenv .env
327330
source .env/bin/activate
328331
pip install ${PADDLE_ROOT}/build/python/dist/*whl
329-
curl ${PADDLE_API_SPEC_URL:-https://raw.githubusercontent.com/PaddlePaddle/FluidAPISpec/master/API.spec} \
330-
> origin.spec
331332
python ${PADDLE_ROOT}/tools/print_signatures.py paddle.fluid > new.spec
332-
python ${PADDLE_ROOT}/tools/diff_api.py origin.spec new.spec
333+
python ${PADDLE_ROOT}/tools/diff_api.py ${PADDLE_ROOT}/paddle/fluid/API.spec new.spec
333334
deactivate
335+
336+
API_CHANGE=`git diff --name-only HEAD^ | grep "paddle/fluid/API.spec"`
337+
echo "checking API.spec change..."
338+
echo "${GIT_PR_ID} , ${API_CHANGE}"
339+
if [ ${API_CHANGE} ] && [ "${GIT_PR_ID}" != "" ]; then
340+
# TODO: curl -H 'Authorization: token ${TOKEN}'
341+
APPROVALS=`curl -H "Authorization: token ${GITHUB_API_TOKEN}" https://api.github.com/repos/PaddlePaddle/Paddle/pulls/${GIT_PR_ID}/reviews | \
342+
python ${PADDLE_ROOT}/tools/check_pr_approval.py 2 7845005 2887803 728699 13348433`
343+
echo "current pr ${GIT_PR_ID} got approvals: ${APPROVALS}"
344+
if [ "${APPROVALS}" == "FALSE" ]; then
345+
echo "You must have at least 2 approvals for the api change!"
346+
exit 1
347+
fi
348+
fi
334349
}
335350

336351

@@ -537,7 +552,6 @@ EOF
537552
}
538553

539554
function main() {
540-
set -e
541555
local CMD=$1
542556
init
543557
case $CMD in

tools/check_pr_approval.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
from __future__ import print_function
16+
import sys
17+
import json
18+
19+
20+
def check_approval(count, required_reviewers):
21+
json_buff = ""
22+
for line in sys.stdin:
23+
json_buff = "".join([json_buff, line])
24+
json_resp = json.loads(json_buff)
25+
approves = 0
26+
approved_user_ids = []
27+
for review in json_resp:
28+
if review["state"] == "APPROVED":
29+
approves += 1
30+
approved_user_ids.append(review["user"]["id"])
31+
32+
# convert to int
33+
required_reviewers_int = set()
34+
for rr in required_reviewers:
35+
required_reviewers_int.add(int(rr))
36+
37+
if len(set(approved_user_ids) & required_reviewers_int) >= count:
38+
print("TRUE")
39+
else:
40+
print("FALSE")
41+
42+
43+
if __name__ == "__main__":
44+
if len(sys.argv) > 1 and sys.argv[1].isdigit():
45+
check_approval(int(sys.argv[1]), sys.argv[2:])
46+
else:
47+
print(
48+
"Usage: python check_pr_approval.py [count] [required reviewer id] ..."
49+
)

0 commit comments

Comments
 (0)