Skip to content

Commit 686eaf2

Browse files
committed
Merge remote-tracking branch 'ups/develop' into fea/jit/rnn
2 parents 0c5ed5f + a4497e6 commit 686eaf2

File tree

20 files changed

+1315
-49
lines changed

20 files changed

+1315
-49
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: 建议(Feature request)
3+
about: 您可以提出您的建议。 You could use this template for reporting a suggestion  issue.
4+
5+
---
6+
7+
欢迎您对PaddlePaddle提出建议,非常感谢您对PaddlePaddle的贡献!
8+
在留下您的建议时,辛苦您同步提供如下信息:
9+
- 版本、环境信息
10+
1)PaddlePaddle版本:请提供您的PaddlePaddle版本号,例如1.1
11+
2)CPU/GPU:您是否使用GPU进行训练,如是,请提供您的CUDA和cuDNN版本号
12+
3)系统环境:请您描述系统类型、版本,例如Mac OS 10.14
13+
- 复现信息:如为报错,请给出复现环境、复现步骤
14+
- 建议描述:请您详细描述,您认为需优化的功能
15+
16+
Thank you for contributing to PaddlePaddle.
17+
Before submitting the issue, you could search issue in the github in case that there was a similar issue submitted or resolved before.
18+
Please make sure that this is a feature request.
19+
**System information**
20+
-PaddlePaddle version (eg.1.1)or CommitID
21+
-CPU: including CPUMKL/OpenBlas/MKLDNN version
22+
-GPU: including CUDA/CUDNN version
23+
-OS Platform (eg.Mac OS 10.14)
24+
**To Reproduce**
25+
Steps to reproduce the behavior
26+
**Describe the feature and the current behavior/state.**
27+
**Any Other info.**
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: 预测(Inference Issue)
3+
about: 您可以提问预测中报错、应用等问题。 You could use this template for reporting an inference issue.
4+
5+
---
6+
7+
为使您的问题得到快速解决,在建立Issue前,请您先通过如下方式搜索是否有相似问题:【搜索issue关键字】【使用labels筛选】【官方文档】
8+
9+
如果您没有查询到相似问题,为快速解决您的提问,建立issue时请提供如下细节信息:
10+
- 标题:简洁、精准描述您的问题,例如“最新预测库的API文档在哪儿 ”
11+
- 版本、环境信息:
12+
   1)PaddlePaddle版本:请提供您的PaddlePaddle版本号(如1.1)或CommitID
13+
   2)CPU:预测若用CPU,请提供CPU型号,MKL/OpenBlas/MKLDNN/等数学库使用情况
14+
   3)GPU:预测若用GPU,请提供GPU型号、CUDA和CUDNN版本号
15+
   4)系统环境:请您描述系统类型、版本(如Mac OS 10.14),Python版本
16+
-预测信息
17+
   1)C++预测:请您提供预测库安装包的版本信息,及其中的version.txt文件
18+
   2)CMake包含路径的完整命令
19+
   3)API信息(如调用请提供)
20+
   4)预测库来源:官网下载/特殊环境(如BCLOUD编译)
21+
- 复现信息:如为报错,请给出复现环境、复现步骤
22+
- 问题描述:请详细描述您的问题,同步贴出报错信息、日志/代码关键片段
23+
24+
Thank you for contributing to PaddlePaddle.
25+
Before submitting the issue, you could search issue in the github in case that th
26+
If there is no solution,please make sure that this is an inference issue including the following details :
27+
**System information**
28+
-PaddlePaddle version (eg.1.1)or CommitID
29+
-CPU: including CPUMKL/OpenBlas/MKLDNN version
30+
-GPU: including CUDA/CUDNN version
31+
-OS Platform (eg.Mac OS 10.14)
32+
-Python version
33+
-Cmake orders
34+
-C++version.txt
35+
-API information
36+
**To Reproduce**
37+
Steps to reproduce the behavior
38+
**Describe your current behavior**
39+
**Code to reproduce the issue**
40+
**Other info / logs**
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: 安装(Installation Issue)
3+
about: 您可以提问安装、编译出现报错等问题。 You could use this template for reporting an installation
4+
 issue.
5+
6+
---
7+
8+
为使您的问题得到快速解决,在建立Issue前,请您先通过如下方式搜索是否有相似问题:【搜索issue关键字】【使用labels筛选】【官方文档】
9+
10+
建立issue时,为快速解决问题,请您根据使用情况给出如下信息:
11+
- 标题:请包含关键词“安装错误”/“编译错误”,例如“Mac编译错误”
12+
- 版本、环境信息:
13+
   1)PaddlePaddle版本:请提供您的PaddlePaddle版本号(如1.1)或CommitID
14+
   2)CPU:请提供CPU型号,MKL/OpenBlas/MKLDNN/等数学库的使用情况
15+
   3)GPU:请提供GPU型号,CUDA和CUDNN版本号
16+
   4)系统环境:请说明系统类型、版本(如Mac OS 10.14)、Python版本
17+
- 安装方式信息:
18+
1)pip安装/docker安装
19+
2)本地编译:请提供cmake命令,编译命令
20+
3)docker编译:请提供docker镜像,编译命令           
21+
 特殊环境请注明:如离线安装等
22+
- 复现信息:如为报错,请给出复现环境、复现步骤
23+
- 问题描述:请详细描述您的问题,同步贴出报错信息、日志/代码关键片段
24+
25+
Thank you for contributing to PaddlePaddle.
26+
Before submitting the issue, you could search issue in Github in case that there was a similar issue submitted or resolved before.
27+
If there is no solution,please make sure that this is an installation issue including the following details:
28+
**System information**
29+
-PaddlePaddle version (eg.1.1)or CommitID
30+
-CPU: including CPUMKL/OpenBlas/MKLDNN version
31+
-GPU: including CUDA/CUDNN version
32+
-OS Platform (eg. Mac OS 10.14)
33+
-Python version
34+
- Install method: pip install/install with docker/build from source(without docker)/build within docker
35+
- Other special cases that you think may be related to this problem, eg. offline install, special internet condition  
36+
**To Reproduce**
37+
Steps to reproduce the behavior
38+
**Describe your current behavior**
39+
**Code to reproduce the issue**
40+
**Other info / logs**
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: 模型(Model Issue)
3+
about: 您可以提问模型、算法、数据集方向的使用报错等问题。You could use this template for reporting a model/
4+
algorithm/dataset  issue.
5+
6+
---
7+
8+
为使您的问题得到快速解决,在建立Issue前,请您先通过如下方式搜索是否有相似问题:【搜索issue关键字】【使用labels筛选】【官方文档】
9+
10+
建立issue时,为快速解决问题,请您根据使用情况给出如下信息:
11+
- 标题:简洁、精准描述您的问题,例如“ssd 模型前置lstm报错  ”
12+
- 版本、环境信息:
13+
   1)PaddlePaddle版本:请提供PaddlePaddle版本号,例如1.1或CommitID
14+
   2)CPU:请提供CPU型号,MKL/OpenBlas/MKLDNN/等数学库的使用情况
15+
   3)GPU:请提供GPU型号,CUDA和CUDNN版本号
16+
   4)系统环境:请说明系统类型、版本(例如Mac OS 10.14),Python版本
17+
- 模型信息
18+
   1)模型名称 2)使用数据集名称 3)使用算法名称 4)模型链接
19+
- 复现信息:如为报错,请给出复现环境、复现步骤
20+
- 问题描述:请详细描述您的问题,同步贴出报错信息、日志/代码关键片段
21+
22+
Thank you for contributing to PaddlePaddle.
23+
Before submitting the issue, you could search issue in the github.Probably there was a similar issue submitted or resolved before.
24+
If there is no solution,please make sure that this is a issue of models including the following details:
25+
**System information**
26+
-PaddlePaddle version (eg.1.1)or CommitID
27+
-CPU: including CPUMKL/OpenBlas/MKLDNN version
28+
-GPU: including CUDA/CUDNN version
29+
-OS Platform (eg.Mac OS 10.14)
30+
-Python version
31+
-Name of Models&Dataset/details of operator
32+
**To Reproduce**
33+
Steps to reproduce the behavior
34+
**Describe your current behavior**
35+
**Code to reproduce the issue**
36+
**Other info / logs**

.github/ISSUE_TEMPLATE/---others-.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: 其他(Others)
3+
about: 如上述分类未包含您的问题,可在此提出。 You could use this template for reporting other issues
4+
5+
---
6+
7+
为使您的问题得到快速解决,在建立Issues前,请您先通过如下方式搜索是否有相似问题:【搜索issue关键字】【使用labels筛选】【官方文档】
8+
9+
如果您没有查询到相似问题,为快速解决您的提问,建立issue时请提供如下细节信息:
10+
- 标题:简洁、精准概括您的问题
11+
- 版本、环境信息:
12+
   1)PaddlePaddle版本:请提供您的PaddlePaddle版本号,例如1.1或CommitID
13+
   2)CPU/GPU:如果您使用GPU训练,请提供GPU驱动版本、CUDA和cuDNN版本号
14+
   3)系统环境:请您描述系统类型、版本,例如Mac OS 10.14
15+
   4)Python版本号
16+
   5)显存信息
17+
- 复现信息:如为报错,请给出复现环境、复现步骤
18+
- 问题描述:请详细描述您的问题,同步贴出报错信息、日志/代码关键片段
19+
20+
Thank you for contributing to PaddlePaddle.
21+
Before submitting the issue, you could search issue in the github in case that there was a similar issue submitted or resolved before.
22+
If there is no solution,please provide us with the following details :
23+
**System information**
24+
-PaddlePaddle version (eg.1.1)or CommitID
25+
-CPU: including CPUMKL/OpenBlas/MKLDNN version
26+
-GPU: including CUDA/cuDNN version
27+
-OS Platform and Distribution(eg.Mac OS 10.14)
28+
-Python version
29+
**To Reproduce**
30+
Steps to reproduce the behavior
31+
**Describe your current behavior**
32+
**Code to reproduce the issue**
33+
**Other info / logs**
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: 训练(Training issue)
3+
about: 您可以提问训练中报错、应用、出core等问题。 You could use this template for reporting an training
4+
 issue.
5+
6+
---
7+
8+
为使您的问题得到快速解决,在建立Issues前,请您先通过如下方式搜索是否有相似问题:【搜索issue关键字】【使用labels筛选】【官方文档】
9+
10+
如果您没有查询到相似问题,为快速解决您的提问,建立issue时请提供如下细节信息:
11+
- 标题:简洁、精准概括您的问题,例如“Insufficient Memory xxx" ”
12+
- 版本、环境信息:
13+
   1)PaddlePaddle版本:请提供您的PaddlePaddle版本号,例如1.1或CommitID
14+
   2)CPU:预测若用CPU,请提供CPU型号,MKL/OpenBlas/MKLDNN/等数学库使用情况
15+
   3)GPU:预测若用GPU,请提供GPU型号、CUDA和CUDNN版本号
16+
   4)系统环境:请您描述系统类型、版本,例如Mac OS 10.14,Python版本
17+
- 训练信息
18+
   1)单机/多机,单卡/多卡
19+
   2)显存信息
20+
   3)Operator信息
21+
- 复现信息:如为报错,请给出复现环境、复现步骤
22+
- 问题描述:请详细描述您的问题,同步贴出报错信息、日志、可复现的代码片段
23+
24+
Thank you for contributing to PaddlePaddle.
25+
Before submitting the issue, you could search issue in the github in case that there was a similar issue submitted or resolved before.
26+
If there is no solution,please make sure that this is a training issue including the following details:
27+
**System information**
28+
-PaddlePaddle version (eg.1.1)or CommitID
29+
-CPU: including CPUMKL/OpenBlas/MKLDNN version
30+
-GPU: including CUDA/CUDNN version
31+
-OS Platform (eg.Mac OS 10.14)
32+
-Other imformation: Distriuted training/informantion of operator/
33+
Graphics card storage
34+
**To Reproduce**
35+
Steps to reproduce the behavior
36+
**Describe your current behavior**
37+
**Code to reproduce the issue**
38+
**Other info / logs**

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ include(external/pybind11) # download pybind11
205205
include(external/cares)
206206
include(external/cub)
207207
include(external/xxhash) # download xxhash
208+
include(external/dlpack)
208209
include(external/snappy) # download snappy
209210
include(external/snappystream) # download snappystream
210211

cmake/external/dlpack.cmake

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
include(ExternalProject)
2+
3+
set(DLPACK_SOURCE_DIR ${THIRD_PARTY_PATH}/dlpack)
4+
set(DLPACK_INCLUDE_DIR ${DLPACK_SOURCE_DIR}/src/extern_dlpack/include)
5+
6+
include_directories(${DLPACK_INCLUDE_DIR})
7+
8+
ExternalProject_Add(
9+
extern_dlpack
10+
${EXTERNAL_PROJECT_LOG_ARGS}
11+
GIT_REPOSITORY "https://github.com/dmlc/dlpack.git"
12+
GIT_TAG "v0.2"
13+
PREFIX ${DLPACK_SOURCE_DIR}
14+
UPDATE_COMMAND ""
15+
CONFIGURE_COMMAND ""
16+
BUILD_COMMAND ""
17+
INSTALL_COMMAND ""
18+
TEST_COMMAND ""
19+
)
20+
21+
if(${CMAKE_VERSION} VERSION_LESS "3.3.0")
22+
set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/dlpack_dummy.c)
23+
file(WRITE ${dummyfile} "const char *dummy = \"${dummyfile}\";")
24+
add_library(dlpack STATIC ${dummyfile})
25+
else()
26+
add_library(dlpack INTERFACE)
27+
endif()
28+
29+
add_dependencies(dlpack extern_dlpack)
30+
31+
LIST(APPEND externl_project_dependencies dlpack)

paddle/fluid/framework/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,6 @@ cc_test(tuple_test SRCS tuple_test.cc )
192192
if (NOT WIN32)
193193
cc_test(rw_lock_test SRCS rw_lock_test.cc)
194194
endif (NOT WIN32)
195+
196+
cc_library(dlpack_tensor SRCS dlpack_tensor.cc DEPS tensor dlpack)
197+
cc_test(dlpack_tensor_test SRCS dlpack_tensor_test.cc DEPS dlpack_tensor glog)
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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/dlpack_tensor.h"
16+
17+
namespace paddle {
18+
namespace framework {
19+
20+
namespace internal {
21+
template <typename T>
22+
static ::DLDataType GetDLDataTypeCode() {
23+
::DLDataType dtype;
24+
if (std::is_same<T, platform::float16>::value ||
25+
std::is_floating_point<T>::value) {
26+
dtype.code = kDLFloat;
27+
} else if (std::is_unsigned<T>::value) {
28+
dtype.code = kDLUInt;
29+
} else if (std::is_integral<T>::value) {
30+
dtype.code = kDLInt;
31+
} else {
32+
PADDLE_THROW("Unsupported data type %s", typeid(T).name());
33+
}
34+
dtype.bits = 8 * sizeof(T);
35+
dtype.lanes = 1;
36+
return dtype;
37+
}
38+
39+
static DLDataType GetDLDataTypeFromTypeIndex(const std::type_index &type) {
40+
#define REG_DL_DATA_TYPE(type) \
41+
{ std::type_index(typeid(type)), GetDLDataTypeCode<type>() }
42+
static const std::unordered_map<std::type_index, ::DLDataType>
43+
type_to_dtype_map({
44+
REG_DL_DATA_TYPE(platform::float16), // NOLINT
45+
REG_DL_DATA_TYPE(float), // NOLINT
46+
REG_DL_DATA_TYPE(double), // NOLINT
47+
REG_DL_DATA_TYPE(int), // NOLINT
48+
REG_DL_DATA_TYPE(int64_t), // NOLINT
49+
REG_DL_DATA_TYPE(bool), // NOLINT
50+
REG_DL_DATA_TYPE(size_t), // NOLINT
51+
REG_DL_DATA_TYPE(int16_t), // NOLINT
52+
REG_DL_DATA_TYPE(uint8_t), // NOLINT
53+
REG_DL_DATA_TYPE(int8_t) // NOLINT
54+
});
55+
static auto type_to_dtype_map_end_it = type_to_dtype_map.end();
56+
auto it = type_to_dtype_map.find(type);
57+
PADDLE_ENFORCE(it != type_to_dtype_map_end_it, "Unsupported data type %s",
58+
type.name());
59+
return it->second;
60+
#undef REG_DL_DATA_TYPE
61+
}
62+
63+
struct DLContextVisitor : public boost::static_visitor<::DLContext> {
64+
inline ::DLContext operator()(const platform::CPUPlace &place) const {
65+
DLContext ctx;
66+
ctx.device_type = kDLCPU;
67+
ctx.device_id = 0;
68+
return ctx;
69+
}
70+
71+
inline ::DLContext operator()(const platform::CUDAPlace &place) const {
72+
#ifdef PADDLE_WITH_CUDA
73+
DLContext ctx;
74+
ctx.device_type = kDLGPU;
75+
ctx.device_id = place.device;
76+
return ctx;
77+
#else
78+
PADDLE_THROW("platform::CUDAPlace is not supported in CPU only version");
79+
#endif
80+
}
81+
82+
inline ::DLContext operator()(const platform::CUDAPinnedPlace &place) const {
83+
#ifdef PADDLE_WITH_CUDA
84+
DLContext ctx;
85+
ctx.device_type = kDLCPUPinned;
86+
ctx.device_id = 0;
87+
return ctx;
88+
#else
89+
PADDLE_THROW(
90+
"platform::CUDAPinnedPlace is not supported in CPU only version");
91+
#endif
92+
}
93+
};
94+
} // namespace internal
95+
96+
DLPackTensor::DLPackTensor(const Tensor &tensor, LaneType lanes) {
97+
// init data, data buffer
98+
t_.data = const_cast<void *>(tensor.data<void>());
99+
100+
// init ctx, DLContext type with device_type and device_id
101+
auto place = tensor.place();
102+
t_.ctx = boost::apply_visitor(internal::DLContextVisitor(), place);
103+
104+
// init dtype
105+
t_.dtype = internal::GetDLDataTypeFromTypeIndex(tensor.type());
106+
t_.dtype.lanes = lanes;
107+
108+
// init ndim, tensor rank
109+
auto &dims = tensor.dims();
110+
using DimType = decltype(t_.ndim); // int
111+
t_.ndim = static_cast<DimType>(dims.size());
112+
113+
// init shape, tensor dims
114+
t_.shape = shape_;
115+
for (DimType i = 0; i < t_.ndim; ++i) {
116+
t_.shape[i] = dims[i];
117+
}
118+
119+
// init strides, nullptr means the tensor is compact
120+
t_.strides = nullptr;
121+
122+
// init byte_offset
123+
t_.byte_offset = 0;
124+
}
125+
126+
} // namespace framework
127+
} // namespace paddle

0 commit comments

Comments
 (0)