Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
379b471e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
379b471e
编写于
9月 03, 2018
作者:
D
dzhwinter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
squash commit
上级
a0aa2ec8
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
43 addition
and
44 deletion
+43
-44
cmake/cuda.cmake
cmake/cuda.cmake
+3
-3
cmake/flags.cmake
cmake/flags.cmake
+1
-3
paddle/fluid/framework/eigen.h
paddle/fluid/framework/eigen.h
+11
-8
paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc
paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc
+10
-9
paddle/fluid/inference/analysis/CMakeLists.txt
paddle/fluid/inference/analysis/CMakeLists.txt
+2
-0
paddle/fluid/operators/CMakeLists.txt
paddle/fluid/operators/CMakeLists.txt
+1
-1
paddle/fluid/operators/cum_op.h
paddle/fluid/operators/cum_op.h
+4
-6
paddle/fluid/operators/math/math_function.cc
paddle/fluid/operators/math/math_function.cc
+9
-0
paddle/fluid/operators/math/math_function.h
paddle/fluid/operators/math/math_function.h
+0
-12
paddle/fluid/operators/math/selected_rows_functor.cu
paddle/fluid/operators/math/selected_rows_functor.cu
+1
-0
paddle/fluid/operators/math/sequence_pooling.cu
paddle/fluid/operators/math/sequence_pooling.cu
+1
-2
未找到文件。
cmake/cuda.cmake
浏览文件 @
379b471e
...
...
@@ -169,9 +169,9 @@ set(CUDA_PROPAGATE_HOST_FLAGS OFF)
# Release/Debug flags set by cmake. Such as -O3 -g -DNDEBUG etc.
# So, don't set these flags here.
#list(APPEND CUDA_NVCC_FLAGS "-std=c++14")
if
(
NOT WIN32
)
# windows msvc2015 support c++11 natively.
# -std=c++11 -fPIC not recoginize by msvc
, -Xcompiler will be added by cmake.
# -std=c++11 -fPIC not recoginize by msvc
list
(
APPEND CUDA_NVCC_FLAGS
"-Xcompiler -fPIC"
)
endif
(
NOT WIN32
)
...
...
@@ -201,4 +201,4 @@ endif()
endif
(
NOT WIN32
)
mark_as_advanced
(
CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD
)
mark_as_advanced
(
CUDA_SDK_ROOT_DIR CUDA_SEPARABLE_COMPILATION
)
mark_as_advanced
(
CUDA_SDK_ROOT_DIR CUDA_SEPARABLE_COMPILATION
)
\ No newline at end of file
cmake/flags.cmake
浏览文件 @
379b471e
...
...
@@ -26,7 +26,6 @@ function(CheckCompilerCXX11Flag)
endfunction
()
CheckCompilerCXX11Flag
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
# safe_set_flag
#
...
...
@@ -136,7 +135,7 @@ else(NOT WIN32)
set
(
COMMON_FLAGS
"/w"
)
#disable all warnings
set
(
GPU_COMMON_FLAGS
-w
)
#disable all warnings
""
)
#disable all warnings
endif
(
NOT WIN32
)
...
...
@@ -160,7 +159,6 @@ if(UNIX AND NOT APPLE)
set
(
LINUX TRUE
)
endif
(
UNIX AND NOT APPLE
)
set
(
GPU_COMMON_FLAGS /std:c++14
${
GPU_COMMON_FLAGS
}
)
foreach
(
flag
${
COMMON_FLAGS
}
)
safe_set_cflag
(
CMAKE_C_FLAGS
${
flag
}
)
safe_set_cxxflag
(
CMAKE_CXX_FLAGS
${
flag
}
)
...
...
paddle/fluid/framework/eigen.h
浏览文件 @
379b471e
...
...
@@ -13,11 +13,10 @@ See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
//
for windows compile eigen with logging
//
logging.h and windows.h conflict
#define GLOG_NO_ABBREVIATED_SEVERITIES
#include "paddle/fluid/framework/tensor.h"
#include <math_constants.h>
#include "unsupported/Eigen/CXX11/Tensor"
namespace
paddle
{
...
...
@@ -49,11 +48,13 @@ struct EigenTensor {
using
ConstType
=
Eigen
::
TensorMap
<
Eigen
::
Tensor
<
const
T
,
D
,
MajorType
,
IndexType
>>
;
static
Type
From
(
Tensor
&
tensor
,
DDim
dims
)
{
static
Type
From
(
Tensor
&
tensor
,
DDim
dims
)
{
// NOLINT
return
Type
(
tensor
.
data
<
T
>
(),
EigenDim
<
D
>::
From
(
dims
));
}
static
Type
From
(
Tensor
&
tensor
)
{
return
From
(
tensor
,
tensor
.
dims_
);
}
static
Type
From
(
Tensor
&
tensor
)
{
// NOLINT
return
From
(
tensor
,
tensor
.
dims_
);
}
// NOLINT
static
ConstType
From
(
const
Tensor
&
tensor
,
DDim
dims
)
{
return
ConstType
(
tensor
.
data
<
T
>
(),
EigenDim
<
D
>::
From
(
dims
));
...
...
@@ -67,7 +68,8 @@ struct EigenTensor {
template
<
typename
T
,
int
MajorType
=
Eigen
::
RowMajor
,
typename
IndexType
=
Eigen
::
DenseIndex
>
struct
EigenMatrix
:
public
EigenTensor
<
T
,
2
,
MajorType
,
IndexType
>
{
static
typename
EigenMatrix
::
Type
Reshape
(
Tensor
&
tensor
,
int
num_col_dims
)
{
static
typename
EigenMatrix
::
Type
Reshape
(
Tensor
&
tensor
,
// NOLINT
int
num_col_dims
)
{
int
rank
=
tensor
.
dims_
.
size
();
PADDLE_ENFORCE
(
num_col_dims
>
0
&&
num_col_dims
<
rank
,
"`num_col_dims` must be between (0, rank_of_tensor)."
);
...
...
@@ -89,11 +91,12 @@ template <typename T, int MajorType = Eigen::RowMajor,
typename
IndexType
=
Eigen
::
DenseIndex
>
struct
EigenVector
:
public
EigenTensor
<
T
,
1
,
MajorType
,
IndexType
>
{
// Flatten reshapes a Tensor into an EigenVector.
static
typename
EigenVector
::
Type
Flatten
(
Tensor
&
tensor
)
{
static
typename
EigenVector
::
Type
Flatten
(
Tensor
&
tensor
)
{
// NOLINT
return
EigenVector
::
From
(
tensor
,
{
product
(
tensor
.
dims_
)});
}
static
typename
EigenVector
::
ConstType
Flatten
(
const
Tensor
&
tensor
)
{
static
typename
EigenVector
::
ConstType
Flatten
(
const
Tensor
&
tensor
)
{
// NOLINT
return
EigenVector
::
From
(
tensor
,
{
product
(
tensor
.
dims_
)});
}
};
...
...
@@ -107,7 +110,7 @@ struct EigenScalar {
using
ConstType
=
Eigen
::
TensorMap
<
Eigen
::
TensorFixedSize
<
const
T
,
Eigen
::
Sizes
<>
,
MajorType
,
IndexType
>>
;
static
Type
From
(
Tensor
&
tensor
)
{
return
Type
(
tensor
.
data
<
T
>
());
}
static
Type
From
(
Tensor
&
tensor
)
{
return
Type
(
tensor
.
data
<
T
>
());
}
// NOLINT
static
ConstType
From
(
const
Tensor
&
tensor
)
{
return
ConstType
(
tensor
.
data
<
T
>
());
...
...
paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc
浏览文件 @
379b471e
...
...
@@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string>
#include "paddle/fluid/framework/ir/attention_lstm_fuse_pass.h"
#include "paddle/fluid/framework/ir/graph_pattern_detector.h"
...
...
@@ -215,12 +216,12 @@ void PrepareLSTMWeight(const LoDTensor& W_forget_w0,
VLOG
(
3
)
<<
"LSTMWeight resized to "
<<
out
->
dims
();
float
*
out_data
=
out
->
mutable_data
<
float
>
(
platform
::
CPUPlace
());
std
::
array
<
const
float
*
,
4
>
tensors
(
{{
W_forget_w0
.
data
<
float
>
(),
W_input_w0
.
data
<
float
>
(),
W_output_w0
.
data
<
float
>
(),
W_cell_w0
.
data
<
float
>
()}})
;
std
::
array
<
const
float
*
,
4
>
tensors1
(
{{
W_forget_w1
.
data
<
float
>
(),
W_input_w1
.
data
<
float
>
(),
W_output_w1
.
data
<
float
>
(),
W_cell_w1
.
data
<
float
>
()}})
;
std
::
array
<
const
float
*
,
4
>
tensors
=
{
W_forget_w0
.
data
<
float
>
(),
W_input_w0
.
data
<
float
>
(),
W_output_w0
.
data
<
float
>
(),
W_cell_w0
.
data
<
float
>
()}
;
std
::
array
<
const
float
*
,
4
>
tensors1
=
{
W_forget_w1
.
data
<
float
>
(),
W_input_w1
.
data
<
float
>
(),
W_output_w1
.
data
<
float
>
(),
W_cell_w1
.
data
<
float
>
()}
;
for
(
int
row
=
0
;
row
<
D
;
row
++
)
{
for
(
int
col
=
0
;
col
<
4
;
col
++
)
{
...
...
@@ -242,9 +243,9 @@ void PrepareLSTMWeight(const LoDTensor& W_forget_w0,
void
PrepareLSTMBias
(
const
LoDTensor
&
B_forget
,
const
LoDTensor
&
B_input
,
const
LoDTensor
&
B_output
,
const
LoDTensor
&
B_cell
,
LoDTensor
*
out
)
{
std
::
array
<
const
float
*
,
4
>
tensors
(
{{
B_forget
.
data
<
float
>
(),
B_input
.
data
<
float
>
(),
B_output
.
data
<
float
>
(),
B_cell
.
data
<
float
>
()}})
;
std
::
array
<
const
float
*
,
4
>
tensors
=
{
B_forget
.
data
<
float
>
(),
B_input
.
data
<
float
>
(),
B_output
.
data
<
float
>
(),
B_cell
.
data
<
float
>
()}
;
PADDLE_ENFORCE_EQ
(
B_forget
.
dims
().
size
(),
1
);
int
D
=
B_forget
.
dims
()[
0
];
...
...
paddle/fluid/inference/analysis/CMakeLists.txt
浏览文件 @
379b471e
...
...
@@ -21,6 +21,7 @@ cc_binary(inference_analyzer SRCS analyzer_main.cc DEPS analysis paddle_fluid)
set
(
PYTHON_TESTS_DIR
${
PADDLE_BINARY_DIR
}
/python/paddle/fluid/tests
)
if
(
NOT WIN32
)
function
(
inference_analysis_test TARGET
)
if
(
WITH_TESTING
)
set
(
options
""
)
...
...
@@ -98,3 +99,4 @@ inference_analysis_test(test_chinese_ner SRCS chinese_ner_tester.cc
ARGS --inference_model_dir=
${
PYTHON_TESTS_DIR
}
/book/word2vec.inference.model
--infer_model=
${
CHINESE_NER_INSTALL_DIR
}
/model
--infer_data=
${
CHINESE_NER_INSTALL_DIR
}
/data.txt
)
endif
(
NOT WIN32
)
paddle/fluid/operators/CMakeLists.txt
浏览文件 @
379b471e
...
...
@@ -87,7 +87,7 @@ function(op_library TARGET)
if
(
WIN32
)
# no nccl, no avx instructions ops.
foreach
(
windows_unsupport_op
"nccl_op"
"gen_nccl_id_op"
"warpctc_op"
"hierarchical_sigmoid_op"
"crf_decoding_op"
"select_op"
"lstmp_op"
"gru_op"
"lstm_op"
"fusion_lstm_op"
)
"crf_decoding_op"
"select_op"
"lstmp_op"
"gru_op"
"lstm_op"
"fusion_lstm_op"
"cumsum_op"
)
if
(
"
${
TARGET
}
"
STREQUAL
"
${
windows_unsupport_op
}
"
)
return
()
endif
()
...
...
paddle/fluid/operators/cum_op.h
浏览文件 @
379b471e
...
...
@@ -85,17 +85,14 @@ class CumKernel : public framework::OpKernel<typename Functor::ELEMENT_TYPE> {
template
<
typename
Device
,
typename
Dim
,
typename
X
,
typename
Out
>
void
ComputeImp
(
Device
d
,
const
Dim
&
dims
,
X
x
,
Out
out
,
int
axis
,
bool
reverse
,
bool
exclusive
)
const
{
Functor
func
();
if
(
!
reverse
)
{
out
.
reshape
(
dims
).
device
(
d
)
=
func
.
apply
(
x
.
reshape
(
dims
),
axis
,
exclusive
);
out
.
reshape
(
dims
).
device
(
d
)
=
Functor
()(
x
.
reshape
(
dims
),
axis
,
exclusive
);
}
else
{
std
::
array
<
bool
,
Dim
::
count
>
rev
;
rev
.
fill
(
false
);
rev
[
axis
]
=
reverse
;
out
.
reshape
(
dims
).
device
(
d
)
=
func
.
apply
(
x
.
reshape
(
dims
).
reverse
(
rev
),
axis
,
exclusive
)
.
reverse
(
rev
);
Functor
()(
x
.
reshape
(
dims
).
reverse
(
rev
),
axis
,
exclusive
).
reverse
(
rev
);
}
}
};
...
...
@@ -104,7 +101,8 @@ template <typename T>
struct
CumsumFunctor
{
using
ELEMENT_TYPE
=
T
;
template
<
typename
X
>
const
typename
X
::
TensorScanSumOp
apply
(
X
x
,
int
axis
,
bool
exclusive
)
const
{
const
typename
X
::
TensorScanSumOp
operator
()(
X
x
,
int
axis
,
bool
exclusive
)
const
{
return
x
.
cumsum
(
axis
,
exclusive
);
}
};
...
...
paddle/fluid/operators/math/math_function.cc
浏览文件 @
379b471e
...
...
@@ -13,6 +13,15 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/operators/math/math_function.h"
#ifdef PADDLE_WITH_MKLML
#include "paddle/fluid/platform/dynload/mklml.h"
#endif
#ifdef PADDLE_USE_OPENBLAS
#include <cblas.h>
#endif
#include <vector>
#include "paddle/fluid/framework/data_type.h"
#include "paddle/fluid/operators/math/math_function_impl.h"
...
...
paddle/fluid/operators/math/math_function.h
浏览文件 @
379b471e
...
...
@@ -13,18 +13,6 @@ See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#ifdef PADDLE_WITH_MKLML
#include "paddle/fluid/platform/dynload/mklml.h"
#endif
#ifdef PADDLE_USE_OPENBLAS
#include <cblas.h>
// remove typedef in openblas
#undef FLOAT
#undef INT
#undef SIZE
#endif
#include <cmath>
#include <vector>
...
...
paddle/fluid/operators/math/selected_rows_functor.cu
浏览文件 @
379b471e
...
...
@@ -16,6 +16,7 @@ limitations under the License. */
#include <vector>
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/math/math_function_impl.h"
#include "paddle/fluid/operators/math/selected_rows_functor.h"
#include "paddle/fluid/platform/cuda_primitives.h"
...
...
paddle/fluid/operators/math/sequence_pooling.cu
浏览文件 @
379b471e
...
...
@@ -16,13 +16,12 @@ limitations under the License. */
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/math/sequence_pooling.h"
#include "paddle/fluid/platform/cuda_primitives.h"
#include "paddle/fluid/platform/macros.h"
namespace
paddle
{
namespace
operators
{
namespace
math
{
#define FLT_MAX __FLT_MAX__
template
<
typename
T
>
struct
MaxPoolFunctor
{
HOSTDEVICE
void
operator
()(
const
T
*
input
,
const
size_t
start
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录