Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
24181fdc
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
694
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
24181fdc
编写于
1月 04, 2018
作者:
Y
Yang Yu
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of github.com:baidu/Paddle into feature/async_drop_kid
上级
8ae84a57
cd5fad13
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
49 addition
and
18 deletion
+49
-18
paddle/framework/init.cc
paddle/framework/init.cc
+5
-0
paddle/framework/init.h
paddle/framework/init.h
+2
-0
paddle/framework/lod_tensor.cc
paddle/framework/lod_tensor.cc
+3
-0
paddle/framework/threadpool.h
paddle/framework/threadpool.h
+5
-6
paddle/operators/activation_op.h
paddle/operators/activation_op.h
+11
-6
paddle/pybind/pybind.cc
paddle/pybind/pybind.cc
+1
-0
python/paddle/v2/fluid/__init__.py
python/paddle/v2/fluid/__init__.py
+3
-2
python/paddle/v2/fluid/layers/ops.py
python/paddle/v2/fluid/layers/ops.py
+19
-4
未找到文件。
paddle/framework/init.cc
浏览文件 @
24181fdc
...
...
@@ -75,5 +75,10 @@ bool InitDevices(const std::vector<std::string> &devices) {
return
true
;
}
void
InitGLOG
(
const
std
::
string
&
prog_name
)
{
google
::
InitGoogleLogging
(
prog_name
.
c_str
());
google
::
InstallFailureSignalHandler
();
}
}
// namespace framework
}
// namespace paddle
paddle/framework/init.h
浏览文件 @
24181fdc
...
...
@@ -22,6 +22,8 @@ namespace framework {
void
InitGflags
(
std
::
vector
<
std
::
string
>
&
argv
);
void
InitGLOG
(
const
std
::
string
&
prog_name
);
bool
InitDevices
(
const
std
::
vector
<
std
::
string
>
&
devices
);
}
// namespace framework
...
...
paddle/framework/lod_tensor.cc
浏览文件 @
24181fdc
...
...
@@ -177,6 +177,9 @@ void AppendLoD(LoD *lod, const LoD &lod_length) {
lod
->
empty
()
||
lod
->
size
()
==
lod_length
.
size
(),
"The lod_length should has the same size with the appended lod."
);
if
(
lod
->
empty
())
{
for
(
size_t
i
=
0
;
i
<
lod_length
.
size
();
++
i
)
{
lod
->
emplace_back
(
1
,
0
);
// size = 1, value = 0;
}
*
lod
=
LoD
(
lod_length
.
size
(),
std
::
vector
<
size_t
>
({
0
}));
}
for
(
size_t
i
=
0
;
i
<
lod
->
size
();
++
i
)
{
...
...
paddle/framework/threadpool.h
浏览文件 @
24181fdc
...
...
@@ -29,7 +29,6 @@ namespace framework {
class
ThreadPool
{
public:
typedef
std
::
packaged_task
<
void
()
>
Task
;
typedef
std
::
function
<
void
()
>
Fun
;
/**
* @brief Get a instance of threadpool, the thread number will
...
...
@@ -67,7 +66,8 @@ class ThreadPool {
* @return std::future<void>, we could wait for the task finished by
* f.wait().
*/
std
::
future
<
void
>
Run
(
const
Fun
&
fn
)
{
template
<
typename
Callback
>
std
::
future
<
void
>
Run
(
Callback
fn
)
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex_
);
Task
task
(
std
::
bind
(
fn
));
std
::
future
<
void
>
f
=
task
.
get_future
();
...
...
@@ -162,10 +162,9 @@ class ThreadPool {
// Run a function asynchronously.
// NOTE: The function must return void. If the function need to return a value,
// you can use lambda to capture a value pointer.
template
<
typename
Callback
,
typename
ARGS
>
std
::
future
<
void
>
Async
(
Callback
callback
,
ARGS
...
args
)
{
return
ThreadPool
::
GetInstance
()
->
Run
(
[
&
]
{
callback
(
std
::
forward
(
args
)...);
});
template
<
typename
Callback
>
std
::
future
<
void
>
Async
(
Callback
callback
)
{
return
ThreadPool
::
GetInstance
()
->
Run
(
callback
);
};
}
// namespace framework
...
...
paddle/operators/activation_op.h
浏览文件 @
24181fdc
...
...
@@ -15,6 +15,7 @@ limitations under the License. */
#pragma once
#include "paddle/framework/eigen.h"
#include "paddle/framework/op_registry.h"
#include "paddle/operators/detail/safe_ref.h"
namespace
paddle
{
namespace
operators
{
...
...
@@ -26,12 +27,16 @@ class ActivationKernel
using
T
=
typename
Functor
::
ELEMENT_TYPE
;
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
auto
*
X
=
context
.
Input
<
framework
::
Tensor
>
(
"X"
);
auto
*
Out
=
context
.
Output
<
framework
::
Tensor
>
(
"Out"
);
Out
->
mutable_data
<
T
>
(
context
.
GetPlace
());
auto
x
=
framework
::
EigenVector
<
T
>::
Flatten
(
*
X
);
auto
out
=
framework
::
EigenVector
<
T
>::
Flatten
(
*
Out
);
auto
&
X
=
detail
::
Ref
(
context
.
Input
<
framework
::
Tensor
>
(
"X"
),
"Cannot get input tensor X, variable name = %s"
,
context
.
op
().
Input
(
"X"
));
auto
&
Out
=
detail
::
Ref
(
context
.
Output
<
framework
::
Tensor
>
(
"Out"
),
"Cannot get output tensor Out, variable name = %s"
,
context
.
op
().
Output
(
"Out"
));
Out
.
mutable_data
<
T
>
(
context
.
GetPlace
());
auto
x
=
framework
::
EigenVector
<
T
>::
Flatten
(
X
);
auto
out
=
framework
::
EigenVector
<
T
>::
Flatten
(
Out
);
auto
*
place
=
context
.
template
device_context
<
DeviceContext
>().
eigen_device
();
Functor
functor
;
...
...
paddle/pybind/pybind.cc
浏览文件 @
24181fdc
...
...
@@ -427,6 +427,7 @@ All parameter, weight, gradient are variables in Paddle.
m
.
def
(
"unique_integer"
,
UniqueIntegerGenerator
);
m
.
def
(
"init_gflags"
,
framework
::
InitGflags
);
m
.
def
(
"init_glog"
,
framework
::
InitGLOG
);
m
.
def
(
"init_devices"
,
&
framework
::
InitDevices
);
m
.
def
(
"is_compile_gpu"
,
IsCompileGPU
);
...
...
python/paddle/v2/fluid/__init__.py
浏览文件 @
24181fdc
...
...
@@ -27,7 +27,7 @@ __all__ = framework.__all__ + executor.__all__ + [
]
def
__
read_gflags_from_env
__
():
def
__
bootstrap
__
():
"""
Enable reading gflags from environment variables.
...
...
@@ -41,6 +41,7 @@ def __read_gflags_from_env__():
read_env_flags
.
append
(
'fraction_of_gpu_memory_to_use'
)
core
.
init_gflags
([
sys
.
argv
[
0
]]
+
[
"--tryfromenv="
+
","
.
join
(
read_env_flags
)])
core
.
init_glog
(
sys
.
argv
[
0
])
if
core
.
is_compile_gpu
():
core
.
init_devices
([
"CPU"
,
"GPU:0"
])
...
...
@@ -48,4 +49,4 @@ def __read_gflags_from_env__():
core
.
init_devices
([
"CPU"
])
__
read_gflags_from_env
__
()
__
bootstrap
__
()
python/paddle/v2/fluid/layers/ops.py
浏览文件 @
24181fdc
from
..registry
import
register_layer
__all__
=
[
'mean'
,
'mul'
,
'dropout'
,
'reshape'
,
'sigmoid'
,
'scale'
,
'transpose'
,
'sigmoid_cross_entropy_with_logits'
,
'elementwise_add'
,
'elementwise_div'
,
'elementwise_sub'
,
'elementwise_mul'
,
'clip'
,
'abs'
,
'sequence_softmax'
__activations__
=
[
'abs'
,
'tanh'
,
'sigmoid'
,
'relu'
,
'sqrt'
,
'ceil'
,
'floor'
,
'log'
,
'round'
]
__all__
=
[
'mean'
,
'mul'
,
'dropout'
,
'reshape'
,
'scale'
,
'transpose'
,
'sigmoid_cross_entropy_with_logits'
,
'elementwise_add'
,
'elementwise_div'
,
'elementwise_sub'
,
'elementwise_mul'
,
'clip'
,
'sequence_softmax'
,
]
+
__activations__
for
_OP
in
set
(
__all__
):
globals
()[
_OP
]
=
register_layer
(
_OP
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录