Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c602e046
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看板
提交
c602e046
编写于
7月 04, 2017
作者:
S
Superjom
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add fake interfaces to make compilable
上级
90f55b1b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
24 deletion
+33
-24
paddle/framework/net.cc
paddle/framework/net.cc
+6
-4
paddle/framework/net.h
paddle/framework/net.h
+26
-18
paddle/framework/net_proto.proto
paddle/framework/net_proto.proto
+1
-2
未找到文件。
paddle/framework/net.cc
浏览文件 @
c602e046
...
...
@@ -5,7 +5,7 @@ namespace framework {
PlainNet
::
PlainNet
(
const
NetDesc
&
def
)
{}
virtual
Error
PlainNet
::
InferShape
(
)
{
Error
PlainNet
::
InferShape
(
Scope
*
scope
)
{
for
(
auto
&
op
:
ops_
)
{
// wrong shape
auto
err
=
op
.
InferShape
();
...
...
@@ -15,9 +15,11 @@ virtual Error PlainNet::InferShape() {
return
Error
();
}
virtual
Error
PlainNet
::
Run
(
Scope
*
scope
=
nullptr
,
OpContext
*
context
=
nullptr
,
OpIndex
begin
=
-
1
,
OpIndex
end
=
-
1
)
const
{}
Error
PlainNet
::
Run
(
Scope
*
scope
,
OpContext
*
context
,
OpIndex
begin
,
OpIndex
end
)
const
{
// TODO Add implementation here.
return
Error
();
}
}
// namespace framework
}
// namespace paddle
paddle/framework/net.h
浏览文件 @
c602e046
...
...
@@ -17,6 +17,7 @@
#include "paddle/framework/net_proto.pb.h"
#include "paddle/framework/op_proto.pb.h"
#include "paddle/framework/scope.h"
#include "paddle/utils/Error.h"
namespace
paddle
{
namespace
framework
{
...
...
@@ -29,11 +30,16 @@ typedef int OpIndex;
* keep updating if the concepts related are implemented.
*/
struct
OpDesc
;
struct
OpDef
;
struct
OpContext
;
struct
OpAttrs
{};
class
Operator
{
public:
Operator
(
const
OpDesc
&
def
)
{}
bool
InferShape
()
{
}
bool
Run
()
{
}
Error
InferShape
()
{
return
Error
();
}
Error
Run
()
{
return
Error
();
}
};
/**
...
...
@@ -55,7 +61,7 @@ class Net {
/**
* @brief Infer shapes of all inputs and outputs of operators.
*/
virtual
bool
InferShape
(
Scope
*
scope
)
override
;
virtual
Error
InferShape
(
Scope
*
scope
)
=
0
;
/**
* @brief Run the network.
*
...
...
@@ -64,28 +70,30 @@ class Net {
* 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.
*/
virtual
bool
Run
(
Scope
*
scope
,
OpContext
*
context
,
OpIndex
begin
=
-
1
,
OpIndex
end
=
-
1
)
const
=
0
;
virtual
Error
Run
(
Scope
*
scope
,
OpContext
*
context
,
OpIndex
begin
=
-
1
,
OpIndex
end
=
-
1
)
const
=
0
;
/**
* @brief Add an Operator according to `def`.
*/
virtual
OpIndex
AddOp
(
const
proto
::
OpDef
&
def
)
=
0
;
virtual
OpIndex
AddOp
(
const
OpDef
&
def
)
=
0
;
/**
* @brief Add optimizer operators acctording to `attrs`.
*/
virtual
bool
AddOptimizerOps
(
const
Opt
Attrs
&
attrs
)
=
0
;
virtual
Error
AddOptimizerOps
(
const
Op
Attrs
&
attrs
)
=
0
;
/**
* @brief Add backward operators.
*/
virtual
bool
AddBackwardOps
()
=
0
;
virtual
Error
AddBackwardOps
()
=
0
;
/**
* @brief Create a network.
*/
static
std
::
unique_ptr
<
Net
>
Create
(
const
NetDesc
&
def
=
NetDesc
());
virtual
~
Net
()
=
0
;
};
/**
...
...
@@ -108,7 +116,7 @@ class PlainNet : public Net {
* Infer all the operators' input and output varialbes' shapes, will be called
* before every mini-batch
*/
virtual
bool
InferShape
(
Scope
*
scope
)
override
;
virtual
Error
InferShape
(
Scope
*
scope
)
override
;
/**
* @brief Run the network.
...
...
@@ -117,23 +125,23 @@ class PlainNet : public Net {
* scope will be used instead. If no OpContext is provicded, default context
* will be used.
*/
virtual
bool
Run
(
Scope
*
scope
=
nullptr
,
OpContext
*
context
=
nullptr
,
OpIndex
begin
=
-
1
,
OpIndex
end
=
-
1
)
const
override
;
virtual
Error
Run
(
Scope
*
scope
=
nullptr
,
OpContext
*
context
=
nullptr
,
OpIndex
begin
=
-
1
,
OpIndex
end
=
-
1
)
const
override
;
/**
* @brief Add an operator to this network.
*/
virtual
OpIndex
AddOp
(
const
proto
::
OpDef
&
def
)
override
;
virtual
OpIndex
AddOp
(
const
OpDef
&
def
)
override
;
/**
* @brief Add all optimizer operators related into the network.
*/
virtual
bool
AddOptimizerOps
(
const
Opt
Attrs
&
attrs
)
override
;
virtual
Error
AddOptimizerOps
(
const
Op
Attrs
&
attrs
)
override
;
/**
* @brief Add all backward operators related into the network.
*/
virtual
bool
AddBackwardOps
()
override
;
virtual
Error
AddBackwardOps
()
override
;
protected:
/**
...
...
@@ -141,7 +149,7 @@ class PlainNet : public Net {
*
* Create operators accordding to `def`, will be called by the constructor.
*/
bool
BuildNet
(
const
NetDesc
&
def
);
Error
BuildNet
(
const
NetDesc
&
def
);
/**
* @brief Add an operator into this network.
...
...
@@ -151,9 +159,9 @@ class PlainNet : public Net {
* `outputs` are keys of mutable output variables. An `OpIndex` will be
* returned to indicate the offset of the new operator in `ops_`.
*/
OpIndex
AddOp
(
const
std
::
string
&
type
,
const
std
::
vector
<
string
>
&
inputs
,
const
std
::
vector
<
string
>
&
outputs
,
const
Op
rAttr
&
attrs
=
OprAttr
());
OpIndex
AddOp
(
const
std
::
string
&
type
,
const
std
::
vector
<
st
d
::
st
ring
>
&
inputs
,
const
std
::
vector
<
st
d
::
st
ring
>
&
outputs
,
const
Op
Attrs
&
attrs
=
OpAttrs
());
private:
// the operators owned by `Network`.
...
...
paddle/framework/net_proto.proto
浏览文件 @
c602e046
syntax
=
"proto2"
;
package
paddle
.
framework
;
import
"op_proto.proto"
import
"op_proto.proto"
;
message
NetDesc
{
// network identification
...
...
@@ -13,4 +13,3 @@ message NetDesc {
// 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录