Skip to content

Commit d50f776

Browse files
committed
merge develop
2 parents 64a08f8 + 900d61d commit d50f776

Some content is hidden

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

55 files changed

+1314
-338
lines changed

cmake/external/anakin.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(ANAKIN_INCLUDE "${ANAKIN_INSTALL_DIR}" CACHE STRING "root of Anakin header f
88
set(ANAKIN_LIBRARY "${ANAKIN_INSTALL_DIR}" CACHE STRING "path of Anakin library")
99

1010
set(ANAKIN_COMPILE_EXTRA_FLAGS
11+
-Wno-error=unused-but-set-variable -Wno-unused-but-set-variable
1112
-Wno-error=unused-variable -Wno-unused-variable
1213
-Wno-error=format-extra-args -Wno-format-extra-args
1314
-Wno-error=comment -Wno-comment
@@ -19,7 +20,7 @@ set(ANAKIN_COMPILE_EXTRA_FLAGS
1920
-Wno-reorder
2021
-Wno-error=cpp)
2122

22-
set(ANAKIN_LIBRARY_URL "https://github.com/pangge/Anakin/releases/download/3.0/anakin_release_simple.tar.gz")
23+
set(ANAKIN_LIBRARY_URL "https://github.com/pangge/Anakin/releases/download/Version0.1.0/anakin.tar.gz")
2324

2425
# A helper function used in Anakin, currently, to use it, one need to recursively include
2526
# nearly all the header files.
@@ -41,9 +42,9 @@ if (NOT EXISTS "${ANAKIN_INSTALL_DIR}")
4142
message(STATUS "Download Anakin library from ${ANAKIN_LIBRARY_URL}")
4243
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
4344
execute_process(COMMAND bash -c "rm -rf ${ANAKIN_INSTALL_DIR}/*")
44-
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; wget -q ${ANAKIN_LIBRARY_URL}")
45+
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; wget --no-check-certificate -q ${ANAKIN_LIBRARY_URL}")
4546
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
46-
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; tar xzf anakin_release_simple.tar.gz")
47+
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; tar xzf anakin.tar.gz")
4748
endif()
4849

4950
if (WITH_ANAKIN)

paddle/fluid/API.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,7 @@ paddle.fluid.layers.gaussian_random_batch_size_like ArgSpec(args=[], varargs='ar
263263
paddle.fluid.layers.scatter ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
264264
paddle.fluid.layers.sum ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
265265
paddle.fluid.layers.slice ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
266-
paddle.fluid.layers.polygon_box_transform ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
267266
paddle.fluid.layers.shape ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
268-
paddle.fluid.layers.iou_similarity ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
269267
paddle.fluid.layers.maxout ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
270268
paddle.fluid.layers.sigmoid ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
271269
paddle.fluid.layers.logsigmoid ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
@@ -306,7 +304,9 @@ paddle.fluid.layers.ssd_loss ArgSpec(args=['location', 'confidence', 'gt_box', '
306304
paddle.fluid.layers.detection_map ArgSpec(args=['detect_res', 'label', 'class_num', 'background_label', 'overlap_threshold', 'evaluate_difficult', 'has_state', 'input_states', 'out_states', 'ap_version'], varargs=None, keywords=None, defaults=(0, 0.3, True, None, None, None, 'integral'))
307305
paddle.fluid.layers.rpn_target_assign ArgSpec(args=['loc', 'scores', 'anchor_box', 'gt_box', 'rpn_batch_size_per_im', 'fg_fraction', 'rpn_positive_overlap', 'rpn_negative_overlap'], varargs=None, keywords=None, defaults=(256, 0.25, 0.7, 0.3))
308306
paddle.fluid.layers.anchor_generator ArgSpec(args=['input', 'anchor_sizes', 'aspect_ratios', 'variance', 'stride', 'offset', 'name'], varargs=None, keywords=None, defaults=(None, None, [0.1, 0.1, 0.2, 0.2], None, 0.5, None))
307+
paddle.fluid.layers.iou_similarity ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
309308
paddle.fluid.layers.box_coder ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
309+
paddle.fluid.layers.polygon_box_transform ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
310310
paddle.fluid.layers.accuracy ArgSpec(args=['input', 'label', 'k', 'correct', 'total'], varargs=None, keywords=None, defaults=(1, None, None))
311311
paddle.fluid.layers.auc ArgSpec(args=['input', 'label', 'curve', 'num_thresholds', 'topk'], varargs=None, keywords=None, defaults=('ROC', 200, 1))
312312
paddle.fluid.layers.exponential_decay ArgSpec(args=['learning_rate', 'decay_steps', 'decay_rate', 'staircase'], varargs=None, keywords=None, defaults=(False,))

paddle/fluid/framework/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cc_library(ddim SRCS ddim.cc DEPS eigen3 boost)
77
cc_test(ddim_test SRCS ddim_test.cc DEPS ddim)
88
nv_test(dim_test SRCS dim_test.cu DEPS ddim)
99
cc_library(data_type SRCS data_type.cc DEPS framework_proto ddim device_context)
10+
cc_test(data_type_test SRCS data_type_test.cc DEPS data_type place tensor)
1011
if(WITH_GPU)
1112
nv_library(tensor SRCS tensor.cc tensor_util.cu DEPS place memory data_type device_context)
1213
else()

paddle/fluid/framework/data_type.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <string>
1818
#include <unordered_map>
1919

20+
using float16 = paddle::platform::float16;
21+
2022
namespace paddle {
2123
namespace framework {
2224

@@ -53,7 +55,7 @@ static DataTypeMap* InitDataTypeMap() {
5355
RegisterType<cc_type>(retv, proto_type, #cc_type)
5456

5557
// NOTE: Add your customize type here.
56-
RegType(platform::float16, proto::VarType::FP16);
58+
RegType(float16, proto::VarType::FP16);
5759
RegType(float, proto::VarType::FP32);
5860
RegType(double, proto::VarType::FP64);
5961
RegType(int, proto::VarType::INT32);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
#include "paddle/fluid/framework/data_type.h"
15+
16+
#include <string>
17+
#include "gtest/gtest.h"
18+
#include "paddle/fluid/framework/tensor.h"
19+
20+
TEST(DataType, float16) {
21+
using paddle::framework::Tensor;
22+
using paddle::platform::CPUPlace;
23+
using paddle::platform::float16;
24+
namespace f = paddle::framework;
25+
f::proto::VarType::Type dtype = f::proto::VarType::FP16;
26+
27+
Tensor tensor;
28+
CPUPlace cpu;
29+
tensor.mutable_data(cpu, f::ToTypeIndex(dtype));
30+
31+
// test fp16 tensor
32+
EXPECT_EQ(tensor.type(), std::type_index(typeid(float16)));
33+
34+
// test fp16 size
35+
EXPECT_EQ(f::SizeOfType(f::ToTypeIndex(dtype)), 2u);
36+
37+
// test debug info
38+
std::string type = "float16";
39+
EXPECT_STREQ(f::DataTypeToString(dtype).c_str(), type.c_str());
40+
}

paddle/fluid/framework/ir/graph_helper_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ TEST(GraphHelperTest, Basic) {
116116
for (size_t i = 0; i < sorted.size(); ++i) {
117117
node_map[sorted[i]->Name()] = i;
118118
}
119-
ASSERT_EQ(node_map.at("op1"), 0);
120-
ASSERT_EQ(node_map.at("op2"), 1);
119+
ASSERT_EQ(node_map.at("op1"), 0UL);
120+
ASSERT_EQ(node_map.at("op2"), 1UL);
121121
ASSERT_TRUE(node_map.at("op3") < node_map.at("op5"));
122122
}
123123
} // namespace ir

paddle/fluid/framework/ir/graph_test.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ TEST(GraphTest, Basic) {
9797
std::vector<ir::Node *> nodes(g->Nodes().begin(), g->Nodes().end());
9898
for (ir::Node *n : nodes) {
9999
if (n->Name() == "sum") {
100-
ASSERT_EQ(n->inputs.size(), 3);
101-
ASSERT_EQ(n->outputs.size(), 1);
100+
ASSERT_EQ(n->inputs.size(), 3UL);
101+
ASSERT_EQ(n->outputs.size(), 1UL);
102102
} else if (n->Name() == "test_a" || n->Name() == "test_b" ||
103103
n->Name() == "test_c") {
104-
ASSERT_EQ(n->inputs.size(), 0);
105-
ASSERT_EQ(n->outputs.size(), 1);
104+
ASSERT_EQ(n->inputs.size(), 0UL);
105+
ASSERT_EQ(n->outputs.size(), 1UL);
106106
} else if (n->Name() == "test_out") {
107-
ASSERT_EQ(n->inputs.size(), 1);
108-
ASSERT_EQ(n->outputs.size(), 0);
107+
ASSERT_EQ(n->inputs.size(), 1UL);
108+
ASSERT_EQ(n->outputs.size(), 0UL);
109109
}
110110
}
111111
ASSERT_EQ(nodes.size(), 5);

paddle/fluid/framework/op_kernel_type_test.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ TEST(OpKernelType, ToString) {
2929
ASSERT_EQ(paddle::framework::KernelTypeToString(op_kernel_type),
3030
"data_type[float]:data_layout[NCHW]:place[CPUPlace]:library_type["
3131
"CUDNN]");
32+
33+
using CUDAPlace = paddle::platform::CUDAPlace;
34+
OpKernelType op_kernel_type2(DataType::FP16, CUDAPlace(0), DataLayout::kNCHW,
35+
LibraryType::kCUDNN);
36+
ASSERT_EQ(paddle::framework::KernelTypeToString(op_kernel_type2),
37+
"data_type[float16]:data_layout[NCHW]:place[CUDAPlace(0)]:library_"
38+
"type[CUDNN]");
3239
}
3340

3441
TEST(OpKernelType, Hash) {

paddle/fluid/framework/op_proto_maker.cc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,40 @@ OpProtoAndCheckerMaker::VariableBuilder OpProtoAndCheckerMaker::AddOutput(
4040
return OpProtoAndCheckerMaker::VariableBuilder{output};
4141
}
4242

43+
void OpProtoAndCheckerMaker::Reuse(const std::string& name,
44+
const std::string& reused_name) {
45+
bool found = false;
46+
proto::OpProto::Var* var;
47+
48+
for (auto& var : proto_->inputs()) {
49+
if (var.name() == reused_name) {
50+
found = true;
51+
break;
52+
}
53+
}
54+
PADDLE_ENFORCE(found == true,
55+
"Input/Output name: %s reused_name: %s, one of them is not "
56+
"exists or not matched.",
57+
name, reused_name);
58+
59+
found = false;
60+
for (int i = 0; i < proto_->outputs().size(); ++i) {
61+
var = proto_->mutable_outputs()->Mutable(i);
62+
if (var->name() == name) {
63+
PADDLE_ENFORCE(!var->has_reuse(),
64+
"Output(%s) has been set reused var of %s", name,
65+
var->reuse());
66+
found = true;
67+
var->set_reuse(reused_name);
68+
break;
69+
}
70+
}
71+
PADDLE_ENFORCE(found == true,
72+
"Input/Output name: %s reused_name: %s, one of them is not "
73+
"exists or not matched.",
74+
name, reused_name);
75+
}
76+
4377
void OpProtoAndCheckerMaker::CheckNoDuplicatedInOutAttrs() {
4478
std::unordered_set<std::string> names;
4579
auto checker = [&](const std::string& name) {

paddle/fluid/framework/op_proto_maker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class OpProtoAndCheckerMaker {
7878
VariableBuilder AddOutput(const std::string &name,
7979
const std::string &comment);
8080

81+
void Reuse(const std::string &name, const std::string &reused_name);
82+
8183
template <typename T>
8284
TypedAttrChecker<T> &AddAttr(const std::string &name,
8385
const std::string &comment,

0 commit comments

Comments
 (0)