Skip to content

Commit e398348

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into port_pybind11
2 parents 99d3f08 + 340a104 commit e398348

Some content is hidden

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

71 files changed

+1344
-393
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ python/paddle/v2/fluid/tests/book/image_classification_resnet.inference.model/
55
python/paddle/v2/fluid/tests/book/image_classification_vgg.inference.model/
66
python/paddle/v2/fluid/tests/book/label_semantic_roles.inference.model/
77
*.DS_Store
8+
*.vs
89
build/
910
build_doc/
1011
*.user
@@ -15,6 +16,7 @@ build_doc/
1516
.cproject
1617
.pydevproject
1718
.settings/
19+
CMakeSettings.json
1820
Makefile
1921
.test_env/
2022
third_party/

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,12 @@ include(external/snappy) # download snappy
204204
include(external/snappystream)
205205
include(external/threadpool)
206206

207-
set(WITH_ANAKIN OFF CACHE STRING "Disable Anakin first, will add it later." FORCE)
208207
if(WITH_GPU)
209208
include(cuda)
210209
include(tensorrt)
211210
include(external/anakin)
211+
elseif()
212+
set(WITH_ANAKIN OFF CACHE STRING "Anakin is used in GPU only now." FORCE)
212213
endif()
213214

214215
include(cudnn) # set cudnn libraries, must before configure

cmake/configure.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ if(NOT CMAKE_CROSSCOMPILING)
5656
set(SIMD_FLAG ${SSE3_FLAG})
5757
endif()
5858
endif()
59+
if(UNIX AND NOT APPLE)
60+
# except apple from nix*Os family
61+
set(LINUX TRUE)
62+
endif(UNIX AND NOT APPLE)
5963

6064
if(NOT WITH_GOLANG)
6165
add_definitions(-DPADDLE_WITHOUT_GOLANG)
@@ -104,6 +108,10 @@ if(WITH_GPU)
104108
if(${CUDNN_MAJOR_VERSION} VERSION_LESS 7)
105109
message(FATAL_ERROR "Anakin needs CUDNN >= 7.0 to compile")
106110
endif()
111+
set(ENV{CUDNN_INCLUDE_DIR} ${CUDNN_INCLUDE_DIR})
112+
set(ENV{CUDNN_LIBRARY} ${CUDNN_LIBRARY})
113+
message(STATUS "cudnn include header is ${CUDNN_INCLUDE_DIR}/cudnn.h")
114+
message(STATUS "cudnn library is ${CUDNN_LIBRARY}")
107115
endif()
108116
elseif(WITH_AMD_GPU)
109117
add_definitions(-DPADDLE_WITH_HIP)

cmake/external/anakin.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ set(ANAKIN_COMPILE_EXTRA_FLAGS
3535
ExternalProject_Add(
3636
extern_anakin
3737
${EXTERNAL_PROJECT_LOG_ARGS}
38-
# TODO(luotao): use PaddlePaddle/Anakin later
39-
GIT_REPOSITORY "https://github.com/luotao1/Anakin"
40-
GIT_TAG "3957ae9263eaa0b1986758dac60a88852afb09be"
38+
GIT_REPOSITORY "https://github.com/PaddlePaddle/Anakin"
39+
GIT_TAG "04256ba78fa3da0beb74e8036c8efd68c12824d6"
4140
PREFIX ${ANAKIN_SOURCE_DIR}
4241
UPDATE_COMMAND ""
4342
CMAKE_ARGS -DUSE_GPU_PLACE=YES

paddle/fluid/API.spec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,11 @@ paddle.fluid.layers.resize_bilinear ArgSpec(args=['input', 'out_shape', 'scale',
155155
paddle.fluid.layers.gather ArgSpec(args=['input', 'index'], varargs=None, keywords=None, defaults=None)
156156
paddle.fluid.layers.random_crop ArgSpec(args=['x', 'shape', 'seed'], varargs=None, keywords=None, defaults=(None,))
157157
paddle.fluid.layers.mean_iou ArgSpec(args=['input', 'label', 'num_classes'], varargs=None, keywords=None, defaults=None)
158-
paddle.fluid.layers.relu ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
159-
paddle.fluid.layers.log ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
158+
paddle.fluid.layers.relu ArgSpec(args=['x', 'name'], varargs=None, keywords=None, defaults=(None,))
159+
paddle.fluid.layers.log ArgSpec(args=['x', 'name'], varargs=None, keywords=None, defaults=(None,))
160160
paddle.fluid.layers.crop ArgSpec(args=['x', 'shape', 'offsets', 'name'], varargs=None, keywords=None, defaults=(None, None, None))
161161
paddle.fluid.layers.rank_loss ArgSpec(args=['label', 'left', 'right', 'name'], varargs=None, keywords=None, defaults=(None,))
162+
paddle.fluid.layers.prelu ArgSpec(args=['x', 'mode', 'param_attr', 'name'], varargs=None, keywords=None, defaults=(None, None))
162163
paddle.fluid.layers.flatten ArgSpec(args=['x', 'axis', 'name'], varargs=None, keywords=None, defaults=(1, None))
163164
paddle.fluid.layers.data ArgSpec(args=['name', 'shape', 'append_batch_size', 'dtype', 'lod_level', 'type', 'stop_gradient'], varargs=None, keywords=None, defaults=(True, 'float32', 0, VarType.LOD_TENSOR, True))
164165
paddle.fluid.layers.open_recordio_file ArgSpec(args=['filename', 'shapes', 'lod_levels', 'dtypes', 'pass_num', 'for_parallel'], varargs=None, keywords=None, defaults=(1, True))

paddle/fluid/framework/attribute.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ struct ExtractAttribute {
128128
attr_value = &boost::get<T>(attr);
129129
} catch (boost::bad_get& bad_get) {
130130
PADDLE_THROW("Cannot get attribute %s by type %s, its type is %s",
131-
attr_name_, typeid(T).name(), attr.type().name());
131+
attr_name_, paddle::platform::demangle(typeid(T).name()),
132+
paddle::platform::demangle(attr.type().name()));
132133
}
133134
return attr_value;
134135
}
@@ -160,7 +161,7 @@ struct ExtractAttribute<bool> {
160161
attr_value = &boost::get<bool>(attr);
161162
} catch (boost::bad_get& bad_get) {
162163
PADDLE_THROW("Cannot get attribute %s by type bool, its type is %s",
163-
attr_name_, attr.type().name());
164+
attr_name_, paddle::platform::demangle(attr.type().name()));
164165
}
165166
return attr_value;
166167
}
@@ -186,7 +187,7 @@ struct ExtractAttribute<int64_t> {
186187
attr_value = &boost::get<int64_t>(attr);
187188
} catch (boost::bad_get& bad_get) {
188189
PADDLE_THROW("Cannot get attribute %s by type int64_t, its type is %s",
189-
attr_name_, attr.type().name());
190+
attr_name_, paddle::platform::demangle(attr.type().name()));
190191
}
191192
return attr_value;
192193
}

paddle/fluid/framework/threadpool.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
DEFINE_int32(io_threadpool_size, 100,
2121
"number of threads used for doing IO, default 100");
2222

23+
DEFINE_int32(dist_threadpool_size, 0,
24+
"number of threads used for distributed executed.");
25+
2326
namespace paddle {
2427
namespace framework {
2528

@@ -35,6 +38,10 @@ void ThreadPool::Init() {
3538
if (threadpool_.get() == nullptr) {
3639
// TODO(Yancey1989): specify the max threads number
3740
int num_threads = std::thread::hardware_concurrency();
41+
if (FLAGS_dist_threadpool_size > 0) {
42+
num_threads = FLAGS_dist_threadpool_size;
43+
VLOG(1) << "set dist_threadpool_size to " << num_threads;
44+
}
3845
PADDLE_ENFORCE_GT(num_threads, 0);
3946
threadpool_.reset(new ThreadPool(num_threads));
4047
}

paddle/fluid/inference/api/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ cc_library(paddle_inference_tensorrt_subgraph_engine
6060
inference_api_test(test_api_tensorrt_subgraph_engine SRC api_tensorrt_subgraph_engine_tester.cc ARGS test_word2vec)
6161
endif()
6262

63-
if (WITH_ANAKIN) # only needed in CI
63+
if (WITH_ANAKIN AND WITH_GPU) # only needed in CI
6464
# compile the libinference_anakin_api.a and anakin.so.
6565
nv_library(inference_anakin_api SRCS api.cc api_anakin_engine.cc DEPS anakin_shared anakin_saber)
6666
#nv_library(inference_anakin_api_shared SHARED SRCS api.cc api_anakin_engine.cc DEPS anakin)

paddle/fluid/operators/CMakeLists.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ function(op_library TARGET)
170170
file(APPEND ${pybind_file} "USE_OP(fake_dequantize_max_abs);\n")
171171
elseif(${TARGET} STREQUAL "tensorrt_engine_op")
172172
message(STATUS "Pybind skips [tensorrt_engine_op], for this OP is only used in inference")
173+
elseif(${TARGET} STREQUAL "fc")
174+
# HACK: fc only have mkldnn and cpu, which would mismatch the cpu only condition
175+
file(APPEND ${pybind_file} "USE_CPU_ONLY_OP(${TARGET});\n")
173176
else()
174177
file(APPEND ${pybind_file} "USE_OP(${TARGET});\n")
175178
endif()
@@ -300,12 +303,6 @@ op_library(channel_recv_op DEPS concurrency)
300303

301304
list(REMOVE_ITEM GENERAL_OPS ${DEPS_OPS})
302305

303-
# The fully connected layer is deleted when the WITH_MKLDNN flag is OFF
304-
# Because the fully connected layer has only one MKLDNN's operator
305-
if(NOT WITH_MKLDNN)
306-
list(REMOVE_ITEM GENERAL_OPS fc_op)
307-
endif(NOT WITH_MKLDNN)
308-
309306
foreach(src ${GENERAL_OPS})
310307
op_library(${src})
311308
endforeach()

paddle/fluid/operators/activation_op.cu

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ namespace plat = paddle::platform;
2626
act_type##_grad, ops::ActivationGradKernel<plat::CUDADeviceContext, \
2727
ops::grad_functor<float>>, \
2828
ops::ActivationGradKernel<plat::CUDADeviceContext, \
29-
ops::grad_functor<double>>);
29+
ops::grad_functor<double>>, \
30+
ops::ActivationGradKernel<plat::CUDADeviceContext, \
31+
ops::grad_functor<plat::float16>>);
3032

3133
FOR_EACH_KERNEL_FUNCTOR(REGISTER_ACTIVATION_CUDA_KERNEL);

0 commit comments

Comments
 (0)