Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
0a46d345
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
0a46d345
编写于
9月 04, 2019
作者:
T
Tao Luo
提交者:
GitHub
9月 04, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine some PADDLE_ENFORCE codes for unify PADDLE_ASSERT_MSG (#19607)
test=develop
上级
a3a4b6e5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
38 addition
and
18 deletion
+38
-18
paddle/fluid/framework/operator.h
paddle/fluid/framework/operator.h
+1
-1
paddle/fluid/operators/conv_cudnn_op.cu.cc
paddle/fluid/operators/conv_cudnn_op.cu.cc
+0
-1
paddle/fluid/operators/gather.h
paddle/fluid/operators/gather.h
+9
-3
paddle/fluid/operators/lstm_unit_op.cu
paddle/fluid/operators/lstm_unit_op.cu
+0
-1
paddle/fluid/operators/math/blas_impl.h
paddle/fluid/operators/math/blas_impl.h
+5
-1
paddle/fluid/operators/scatter.cu.h
paddle/fluid/operators/scatter.cu.h
+8
-4
paddle/fluid/operators/scatter.h
paddle/fluid/operators/scatter.h
+15
-7
未找到文件。
paddle/fluid/framework/operator.h
浏览文件 @
0a46d345
...
...
@@ -341,7 +341,7 @@ class ExecutionContext {
#ifdef PADDLE_WITH_CUDA
const
inline
platform
::
CUDADeviceContext
&
cuda_device_context
()
const
{
PADDLE_ENFORCE
(
platform
::
is_gpu_place
(
device_context_
.
GetPlace
())
);
PADDLE_ENFORCE
_EQ
(
platform
::
is_gpu_place
(
device_context_
.
GetPlace
()),
true
);
return
*
reinterpret_cast
<
const
platform
::
CUDADeviceContext
*>
(
&
device_context_
);
}
...
...
paddle/fluid/operators/conv_cudnn_op.cu.cc
浏览文件 @
0a46d345
...
...
@@ -18,7 +18,6 @@ limitations under the License. */
#include "paddle/fluid/operators/conv_cudnn_helper.h"
#include "paddle/fluid/operators/conv_cudnn_op_cache.h"
#include "paddle/fluid/operators/conv_op.h"
#include "paddle/fluid/platform/assert.h"
#include "paddle/fluid/platform/cudnn_helper.h"
#include "paddle/fluid/platform/cudnn_workspace_helper.h"
#include "paddle/fluid/platform/float16.h"
...
...
paddle/fluid/operators/gather.h
浏览文件 @
0a46d345
...
...
@@ -36,10 +36,16 @@ using framework::Tensor;
template
<
typename
T
,
typename
IndexT
=
int
>
void
CPUGather
(
const
platform
::
DeviceContext
&
ctx
,
const
Tensor
&
src
,
const
Tensor
&
index
,
Tensor
*
output
)
{
PADDLE_ENFORCE
(
platform
::
is_cpu_place
(
ctx
.
GetPlace
())
);
PADDLE_ENFORCE
_EQ
(
platform
::
is_cpu_place
(
ctx
.
GetPlace
()),
true
);
// check index of shape 1-D
PADDLE_ENFORCE
(
index
.
dims
().
size
()
==
1
||
(
index
.
dims
().
size
()
==
2
&&
index
.
dims
()[
1
]
==
1
));
if
(
index
.
dims
().
size
()
==
2
)
{
PADDLE_ENFORCE_EQ
(
index
.
dims
()[
1
],
1
,
"index.dims()[1] should be 1 when index.dims().size() == "
"2 in gather_op."
);
}
else
{
PADDLE_ENFORCE_EQ
(
index
.
dims
().
size
(),
1
,
"index.dims().size() should be 1 or 2 in gather_op."
);
}
int64_t
index_size
=
index
.
dims
()[
0
];
auto
src_dims
=
src
.
dims
();
...
...
paddle/fluid/operators/lstm_unit_op.cu
浏览文件 @
0a46d345
...
...
@@ -19,7 +19,6 @@ https://github.com/caffe2/caffe2/blob/master/caffe2/operators/lstm_unit_op_gpu.c
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/cross_entropy_op.h"
#include "paddle/fluid/operators/lstm_unit_op.h"
#include "paddle/fluid/platform/assert.h"
#include "paddle/fluid/platform/hostdevice.h"
namespace
paddle
{
...
...
paddle/fluid/operators/math/blas_impl.h
浏览文件 @
0a46d345
...
...
@@ -666,7 +666,11 @@ void Blas<DeviceContext>::MatMul(const framework::Tensor &mat_a,
mat_b
.
data
<
T
>
(),
beta
,
mat_out
->
data
<
T
>
());
}
else
{
PADDLE_ENFORCE
(
dim_a
.
batch_size_
==
dim_b
.
batch_size_
||
dim_a
.
batch_size_
==
0
||
dim_b
.
batch_size_
==
0
);
dim_a
.
batch_size_
==
0
||
dim_b
.
batch_size_
==
0
,
"dim_a.batch_size should be equal to dim_b.batch_size, or "
"one of dim_a.batch_size and dim_b.batch_size should be 0. "
"But got dim_a.batch_size = %d, dim_b.batch_size = %d."
,
dim_a
.
batch_size_
,
dim_b
.
batch_size_
);
this
->
template
BatchedGEMM
<
T
>(
transA
,
transB
,
dim_a
.
height_
,
dim_b
.
width_
,
dim_a
.
width_
,
alpha
,
mat_a
.
data
<
T
>
(),
mat_b
.
data
<
T
>
(),
beta
,
mat_out
->
data
<
T
>
(),
...
...
paddle/fluid/operators/scatter.cu.h
浏览文件 @
0a46d345
...
...
@@ -90,12 +90,16 @@ template <typename T, typename IndexT = int>
void
GPUScatterAssign
(
const
framework
::
ExecutionContext
&
context
,
const
Tensor
&
src
,
const
Tensor
&
index
,
Tensor
*
output
,
bool
overwrite
=
true
)
{
// PADDLE_ENFORCE(platform::is_gpu_place(place));
// check index of shape 1-D
const
auto
&
ctx
=
context
.
device_context
();
PADDLE_ENFORCE
(
index
.
dims
().
size
()
==
1
||
(
index
.
dims
().
size
()
==
2
&&
index
.
dims
()[
1
]
==
1
));
if
(
index
.
dims
().
size
()
==
2
)
{
PADDLE_ENFORCE_EQ
(
index
.
dims
()[
1
],
1
,
"index.dims()[1] should be 1 when index.dims().size() == "
"2 in scatter_op."
);
}
else
{
PADDLE_ENFORCE_EQ
(
index
.
dims
().
size
(),
1
,
"index.dims().size() should be 1 or 2 in scatter_op."
);
}
int
index_size
=
index
.
dims
()[
0
];
auto
src_dims
=
src
.
dims
();
...
...
paddle/fluid/operators/scatter.h
浏览文件 @
0a46d345
...
...
@@ -73,10 +73,16 @@ elementwise_inner_add(const framework::ExecutionContext& ctx,
template
<
typename
T
,
typename
IndexT
=
int
>
void
ScatterAssign
(
const
platform
::
DeviceContext
&
ctx
,
const
Tensor
&
src
,
const
Tensor
&
index
,
Tensor
*
output
)
{
PADDLE_ENFORCE
(
platform
::
is_cpu_place
(
ctx
.
GetPlace
())
);
PADDLE_ENFORCE
_EQ
(
platform
::
is_cpu_place
(
ctx
.
GetPlace
()),
true
);
// check index of shape 1-D
PADDLE_ENFORCE
(
index
.
dims
().
size
()
==
1
||
(
index
.
dims
().
size
()
==
2
&&
index
.
dims
()[
1
]
==
1
));
if
(
index
.
dims
().
size
()
==
2
)
{
PADDLE_ENFORCE_EQ
(
index
.
dims
()[
1
],
1
,
"index.dims()[1] should be 1 when index.dims().size() == "
"2 in scatter_op."
);
}
else
{
PADDLE_ENFORCE_EQ
(
index
.
dims
().
size
(),
1
,
"index.dims().size() should be 1 or 2 in scatter_op."
);
}
int
index_size
=
index
.
dims
()[
0
];
auto
src_dims
=
src
.
dims
();
...
...
@@ -88,7 +94,7 @@ void ScatterAssign(const platform::DeviceContext& ctx, const Tensor& src,
// check src shape and dst shape should match
for
(
int
i
=
1
;
i
<
src_dims
.
size
();
i
++
)
PADDLE_ENFORCE
(
src_dims
[
i
]
==
dst_dims
[
i
]);
PADDLE_ENFORCE
_EQ
(
src_dims
[
i
],
dst_dims
[
i
]);
// slice size
size_t
slice_size
=
1
;
...
...
@@ -105,10 +111,12 @@ void ScatterAssign(const platform::DeviceContext& ctx, const Tensor& src,
template
<
typename
T
,
typename
IndexT
=
int
>
void
ScatterAssignAdd
(
const
framework
::
ExecutionContext
&
ctx
,
const
Tensor
&
src
,
const
Tensor
&
index
,
Tensor
*
output
)
{
PADDLE_ENFORCE
(
platform
::
is_cpu_place
(
ctx
.
device_context
().
GetPlace
()));
PADDLE_ENFORCE_EQ
(
platform
::
is_cpu_place
(
ctx
.
device_context
().
GetPlace
()),
true
);
// check index of shape 1-D
PADDLE_ENFORCE
(
index
.
dims
().
size
()
==
1
||
(
index
.
dims
().
size
()
==
2
&&
index
.
dims
()[
1
]
==
1
));
(
index
.
dims
().
size
()
==
2
&&
index
.
dims
()[
1
]
==
1
),
""
);
int
index_size
=
index
.
dims
()[
0
];
auto
src_dims
=
src
.
dims
();
...
...
@@ -122,7 +130,7 @@ void ScatterAssignAdd(const framework::ExecutionContext& ctx, const Tensor& src,
// check src shape and dst shape should match
for
(
int
i
=
1
;
i
<
src_dims
.
size
();
i
++
)
PADDLE_ENFORCE
(
src_dims
[
i
]
==
dst_dims
[
i
]);
PADDLE_ENFORCE
_EQ
(
src_dims
[
i
],
dst_dims
[
i
]);
// slice size
size_t
slice_size
=
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录