Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
225a8fa1
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
225a8fa1
编写于
1月 23, 2017
作者:
H
hedaoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add numInputs_ and numOutputs_
上级
50e525ca
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
4 deletion
+27
-4
paddle/function/CrossMapNormalOp.cpp
paddle/function/CrossMapNormalOp.cpp
+14
-4
paddle/function/Function.h
paddle/function/Function.h
+13
-0
未找到文件。
paddle/function/CrossMapNormalOp.cpp
浏览文件 @
225a8fa1
...
@@ -162,14 +162,19 @@ template <DeviceType Device>
...
@@ -162,14 +162,19 @@ template <DeviceType Device>
class
CrossMapNormalFunc
:
public
FunctionBase
{
class
CrossMapNormalFunc
:
public
FunctionBase
{
public:
public:
void
init
(
const
FuncConfig
&
config
)
override
{
void
init
(
const
FuncConfig
&
config
)
override
{
// function arguments
size_
=
config
.
get
<
size_t
>
(
"size"
);
size_
=
config
.
get
<
size_t
>
(
"size"
);
scale_
=
config
.
get
<
real
>
(
"scale"
);
scale_
=
config
.
get
<
real
>
(
"scale"
);
pow_
=
config
.
get
<
real
>
(
"pow"
);
pow_
=
config
.
get
<
real
>
(
"pow"
);
// number of inputs and outputs
numInputs_
=
1
;
numOutputs_
=
2
;
}
}
void
calc
(
const
BufferArgs
&
inputs
,
const
BufferArgs
&
outputs
)
override
{
void
calc
(
const
BufferArgs
&
inputs
,
const
BufferArgs
&
outputs
)
override
{
CHECK_EQ
((
size_t
)
1
,
inputs
.
size
());
CHECK_EQ
((
size_t
)
numInputs_
,
inputs
.
size
());
CHECK_EQ
((
size_t
)
2
,
outputs
.
size
());
CHECK_EQ
((
size_t
)
numOutputs_
,
outputs
.
size
());
CHECK_EQ
(
inputs
[
0
].
shape
().
ndims
(),
(
size_t
)
4
);
CHECK_EQ
(
inputs
[
0
].
shape
().
ndims
(),
(
size_t
)
4
);
CHECK
(
inputs
[
0
].
shape
()
==
outputs
[
0
].
shape
());
CHECK
(
inputs
[
0
].
shape
()
==
outputs
[
0
].
shape
());
...
@@ -236,14 +241,19 @@ template <DeviceType Device>
...
@@ -236,14 +241,19 @@ template <DeviceType Device>
class
CrossMapNormalGradFunc
:
public
FunctionBase
{
class
CrossMapNormalGradFunc
:
public
FunctionBase
{
public:
public:
void
init
(
const
FuncConfig
&
config
)
override
{
void
init
(
const
FuncConfig
&
config
)
override
{
// function arguments
size_
=
config
.
get
<
size_t
>
(
"size"
);
size_
=
config
.
get
<
size_t
>
(
"size"
);
scale_
=
config
.
get
<
real
>
(
"scale"
);
scale_
=
config
.
get
<
real
>
(
"scale"
);
pow_
=
config
.
get
<
real
>
(
"pow"
);
pow_
=
config
.
get
<
real
>
(
"pow"
);
// number of inputs and outputs
numInputs_
=
4
;
numOutputs_
=
1
;
}
}
void
calc
(
const
BufferArgs
&
inputs
,
const
BufferArgs
&
outputs
)
override
{
void
calc
(
const
BufferArgs
&
inputs
,
const
BufferArgs
&
outputs
)
override
{
CHECK_EQ
((
size_t
)
4
,
inputs
.
size
());
CHECK_EQ
((
size_t
)
numInputs_
,
inputs
.
size
());
CHECK_EQ
((
size_t
)
1
,
outputs
.
size
());
CHECK_EQ
((
size_t
)
numOutputs_
,
outputs
.
size
());
CHECK_EQ
(
inputs
[
0
].
shape
().
ndims
(),
(
size_t
)
4
);
CHECK_EQ
(
inputs
[
0
].
shape
().
ndims
(),
(
size_t
)
4
);
CHECK
(
inputs
[
0
].
shape
()
==
inputs
[
1
].
shape
());
CHECK
(
inputs
[
0
].
shape
()
==
inputs
[
1
].
shape
());
...
...
paddle/function/Function.h
浏览文件 @
225a8fa1
...
@@ -153,7 +153,20 @@ public:
...
@@ -153,7 +153,20 @@ public:
virtual
void
calc
(
const
BufferArgs
&
inputs
,
const
BufferArgs
&
outputs
)
{}
virtual
void
calc
(
const
BufferArgs
&
inputs
,
const
BufferArgs
&
outputs
)
{}
int
getNumInputs
()
const
{
return
numInputs_
;
}
int
getNumOutputs
()
const
{
return
numOutputs_
;
}
static
ClassRegistrar
<
FunctionBase
>
funcRegistrar_
;
static
ClassRegistrar
<
FunctionBase
>
funcRegistrar_
;
protected:
// numInputs_ and numOutputs_ represents the maximum
// input and output supported by Function.
// Some functions are optimized for input and output,
// so when comparing the number of arguments, for these functions
// inputs.size() <= numInputs_ or outputs.size() <= numOutputs_
size_t
numInputs_
;
size_t
numOutputs_
;
};
};
#define FUNC_NAME(typeName, deviceName) #typeName "-" #deviceName
#define FUNC_NAME(typeName, deviceName) #typeName "-" #deviceName
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录