Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
9f365d36
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9f365d36
编写于
7月 04, 2017
作者:
D
dongzhihong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"add net proto"
上级
aadbd498
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
33 deletion
+35
-33
paddle/framework/CMakeLists.txt
paddle/framework/CMakeLists.txt
+4
-0
paddle/framework/net.h
paddle/framework/net.h
+15
-33
paddle/framework/net_proto.proto
paddle/framework/net_proto.proto
+16
-0
未找到文件。
paddle/framework/CMakeLists.txt
浏览文件 @
9f365d36
...
@@ -7,4 +7,8 @@ cc_test(scope_test SRCS scope_test.cc)
...
@@ -7,4 +7,8 @@ cc_test(scope_test SRCS scope_test.cc)
cc_test
(
enforce_test SRCS enforce_test.cc
)
cc_test
(
enforce_test SRCS enforce_test.cc
)
proto_library
(
attr_type SRCS attr_type.proto
)
proto_library
(
attr_type SRCS attr_type.proto
)
proto_library
(
op_proto SRCS op_proto.proto
)
proto_library
(
op_proto SRCS op_proto.proto
)
cc_test
(
op_proto_test SRCS op_proto_test.cc DEPS op_proto attr_type protobuf
)
cc_test
(
op_proto_test SRCS op_proto_test.cc DEPS op_proto attr_type protobuf
)
proto_library
(
net_proto SRCS net_proto.proto
)
cc_library
(
net SRCS net.cc DEPS net_proto attr_type op_proto
)
paddle/framework/net.h
浏览文件 @
9f365d36
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
#pragma once
#pragma once
#include "paddle/framework/net_proto.pb.h"
#include "paddle/framework/op_proto.pb.h"
#include "paddle/framework/scope.h"
#include "paddle/framework/scope.h"
namespace
paddle
{
namespace
paddle
{
...
@@ -27,31 +29,11 @@ typedef int OpIndex;
...
@@ -27,31 +29,11 @@ typedef int OpIndex;
* keep updating if the concepts related are implemented.
* keep updating if the concepts related are implemented.
*/
*/
// Operator's runtime context.
struct
OpContext
{
int
dev_id
;
DevType
dev_type
{
kCPU
};
enum
DevType
{
kCPU
,
kGPU
};
};
// Proto definitions, use `struct`s for simpility.
struct
VarDesc
{
std
::
string
type
;
std
::
vector
<
int
>
dims
;
};
struct
OpDesc
{
std
::
string
type
;
std
::
vector
<
VarDesc
>
inputs
;
std
::
vector
<
VarDesc
>
outputs
;
};
struct
struct
NetDesc
{
std
::
vector
<
OpDesc
>
ops
;
};
class
Operator
{
class
Operator
{
public:
public:
Operator
(
const
OpDesc
&
def
)
{}
Operator
(
const
OpDesc
&
def
)
{}
Error
InferShape
()
{}
bool
InferShape
()
{}
Error
Run
()
{}
bool
Run
()
{}
};
};
/**
/**
...
@@ -73,7 +55,7 @@ class Net {
...
@@ -73,7 +55,7 @@ class Net {
/**
/**
* @brief Infer shapes of all inputs and outputs of operators.
* @brief Infer shapes of all inputs and outputs of operators.
*/
*/
virtual
Error
InferShape
(
Scope
*
scope
)
override
;
virtual
bool
InferShape
(
Scope
*
scope
)
override
;
/**
/**
* @brief Run the network.
* @brief Run the network.
*
*
...
@@ -82,8 +64,8 @@ class Net {
...
@@ -82,8 +64,8 @@ class Net {
* environment for ops. `begin` and `end` specify the scope of `ops_` to run,
* environment for ops. `begin` and `end` specify the scope of `ops_` to run,
* If no positive indexes are provided, all operators in `ops_` will run.
* If no positive indexes are provided, all operators in `ops_` will run.
*/
*/
virtual
Error
Run
(
Scope
*
scope
,
OpContext
*
context
,
OpIndex
begin
=
-
1
,
virtual
bool
Run
(
Scope
*
scope
,
OpContext
*
context
,
OpIndex
begin
=
-
1
,
OpIndex
end
=
-
1
)
const
=
0
;
OpIndex
end
=
-
1
)
const
=
0
;
/**
/**
* @brief Add an Operator according to `def`.
* @brief Add an Operator according to `def`.
...
@@ -93,12 +75,12 @@ class Net {
...
@@ -93,12 +75,12 @@ class Net {
/**
/**
* @brief Add optimizer operators acctording to `attrs`.
* @brief Add optimizer operators acctording to `attrs`.
*/
*/
virtual
Error
AddOptimizerOps
(
const
OptAttrs
&
attrs
)
=
0
;
virtual
bool
AddOptimizerOps
(
const
OptAttrs
&
attrs
)
=
0
;
/**
/**
* @brief Add backward operators.
* @brief Add backward operators.
*/
*/
virtual
Error
AddBackwardOps
()
=
0
;
virtual
bool
AddBackwardOps
()
=
0
;
/**
/**
* @brief Create a network.
* @brief Create a network.
...
@@ -126,7 +108,7 @@ class PlainNet : public Net {
...
@@ -126,7 +108,7 @@ class PlainNet : public Net {
* Infer all the operators' input and output varialbes' shapes, will be called
* Infer all the operators' input and output varialbes' shapes, will be called
* before every mini-batch
* before every mini-batch
*/
*/
virtual
Error
InferShape
(
Scope
*
scope
)
override
;
virtual
bool
InferShape
(
Scope
*
scope
)
override
;
/**
/**
* @brief Run the network.
* @brief Run the network.
...
@@ -135,8 +117,8 @@ class PlainNet : public Net {
...
@@ -135,8 +117,8 @@ class PlainNet : public Net {
* scope will be used instead. If no OpContext is provicded, default context
* scope will be used instead. If no OpContext is provicded, default context
* will be used.
* will be used.
*/
*/
virtual
Error
Run
(
Scope
*
scope
=
nullptr
,
OpContext
*
context
=
nullptr
,
virtual
bool
Run
(
Scope
*
scope
=
nullptr
,
OpContext
*
context
=
nullptr
,
OpIndex
begin
=
-
1
,
OpIndex
end
=
-
1
)
const
override
;
OpIndex
begin
=
-
1
,
OpIndex
end
=
-
1
)
const
override
;
/**
/**
* @brief Add an operator to this network.
* @brief Add an operator to this network.
...
@@ -146,12 +128,12 @@ class PlainNet : public Net {
...
@@ -146,12 +128,12 @@ class PlainNet : public Net {
/**
/**
* @brief Add all optimizer operators related into the network.
* @brief Add all optimizer operators related into the network.
*/
*/
virtual
Error
AddOptimizerOps
(
const
OptAttrs
&
attrs
)
override
;
virtual
bool
AddOptimizerOps
(
const
OptAttrs
&
attrs
)
override
;
/**
/**
* @brief Add all backward operators related into the network.
* @brief Add all backward operators related into the network.
*/
*/
virtual
Error
AddBackwardOps
()
override
;
virtual
bool
AddBackwardOps
()
override
;
protected:
protected:
/**
/**
...
@@ -159,7 +141,7 @@ class PlainNet : public Net {
...
@@ -159,7 +141,7 @@ class PlainNet : public Net {
*
*
* Create operators accordding to `def`, will be called by the constructor.
* Create operators accordding to `def`, will be called by the constructor.
*/
*/
Error
BuildNet
(
const
NetDesc
&
def
);
bool
BuildNet
(
const
NetDesc
&
def
);
/**
/**
* @brief Add an operator into this network.
* @brief Add an operator into this network.
...
...
paddle/framework/net_proto.proto
0 → 100644
浏览文件 @
9f365d36
syntax
=
"proto2"
;
package
paddle
.
framework
;
import
"op_proto.proto"
message
NetDesc
{
// network identification
optional
string
name
=
1
;
// operator contains in network
repeated
OpProto
operators
=
2
;
// network type to run with. e.g "plainNet", "DAG"
optional
string
type
=
3
;
// num worker always
optional
int32
num_workers
=
4
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录