Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
2c05465d
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2c05465d
编写于
9月 27, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix unit-tests
上级
3a5693e0
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
70 addition
and
2 deletion
+70
-2
paddle/framework/operator_test.cc
paddle/framework/operator_test.cc
+5
-2
paddle/operators/gather_op.cc
paddle/operators/gather_op.cc
+10
-0
paddle/operators/gaussian_random_op.cc
paddle/operators/gaussian_random_op.cc
+7
-0
paddle/operators/lookup_table_op.cc
paddle/operators/lookup_table_op.cc
+10
-0
paddle/operators/multiplex_op.cc
paddle/operators/multiplex_op.cc
+10
-0
paddle/operators/scatter_op.cc
paddle/operators/scatter_op.cc
+10
-0
paddle/operators/softmax_with_cross_entropy_op.cc
paddle/operators/softmax_with_cross_entropy_op.cc
+11
-0
paddle/operators/uniform_random_op.cc
paddle/operators/uniform_random_op.cc
+7
-0
未找到文件。
paddle/framework/operator_test.cc
浏览文件 @
2c05465d
...
...
@@ -116,10 +116,13 @@ class OpWithKernelTest : public OperatorWithKernel {
protected:
void
InferShape
(
framework
::
InferShapeContextBase
*
ctx
)
const
override
{}
DataType
IndicateDataType
(
const
ExecutionContext
&
ctx
)
const
override
{
return
DataType
::
FP32
;
}
};
template
<
typename
T1
,
typename
T2
>
class
CPUKernelTest
:
public
OpKernel
{
class
CPUKernelTest
:
public
OpKernel
<
float
>
{
public:
void
Compute
(
const
ExecutionContext
&
ctx
)
const
{
std
::
cout
<<
"this is cpu kernel"
<<
std
::
endl
;
...
...
@@ -146,7 +149,7 @@ class OpKernelTestMultiInputsProtoAndCheckerMaker
}
};
class
CPUKernalMultiInputsTest
:
public
OpKernel
{
class
CPUKernalMultiInputsTest
:
public
OpKernel
<
float
>
{
public:
void
Compute
(
const
ExecutionContext
&
ctx
)
const
{
auto
xs
=
ctx
.
op
().
Inputs
(
"xs"
);
...
...
paddle/operators/gather_op.cc
浏览文件 @
2c05465d
...
...
@@ -37,6 +37,11 @@ class GatherOp : public framework::OperatorWithKernel {
output_dims
[
0
]
=
batch_size
;
ctx
->
SetOutputDim
(
"Out"
,
output_dims
);
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
ToDataType
(
ctx
.
Input
<
Tensor
>
(
"X"
)
->
type
());
}
};
class
GatherGradOp
:
public
framework
::
OperatorWithKernel
{
...
...
@@ -47,6 +52,11 @@ class GatherGradOp : public framework::OperatorWithKernel {
void
InferShape
(
framework
::
InferShapeContextBase
*
ctx
)
const
override
{
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"X"
),
ctx
->
GetInputDim
(
"X"
));
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
ToDataType
(
ctx
.
Input
<
Tensor
>
(
"X"
)
->
type
());
}
};
class
GatherOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
...
...
paddle/operators/gaussian_random_op.cc
浏览文件 @
2c05465d
...
...
@@ -56,6 +56,11 @@ class GaussianRandomOp : public framework::OperatorWithKernel {
"dims can be one int or array. dims must be set."
);
ctx
->
SetOutputDim
(
"Out"
,
framework
::
make_ddim
(
temp
));
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
static_cast
<
framework
::
DataType
>
(
Attr
<
int
>
(
"data_type"
));
}
};
class
GaussianRandomOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
...
...
@@ -76,6 +81,8 @@ Use to initialize tensor with gaussian random generator.
"Random seed of generator."
"0 means use system wide seed"
)
.
SetDefault
(
0
);
AddAttr
<
int
>
(
"data_type"
,
"output data type"
)
.
SetDefault
(
framework
::
DataType
::
FP32
);
}
};
...
...
paddle/operators/lookup_table_op.cc
浏览文件 @
2c05465d
...
...
@@ -36,6 +36,11 @@ class LookupTableOp : public framework::OperatorWithKernel {
ctx
->
SetOutputDim
(
"Out"
,
{
ids_dims
[
0
],
table_dims
[
1
]});
ctx
->
ShareLoD
(
"Ids"
,
/*->*/
"Out"
);
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
ToDataType
(
ctx
.
Input
<
Tensor
>
(
"W"
)
->
type
());
}
};
class
LookupTableOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
...
...
@@ -69,6 +74,11 @@ class LookupTableOpGrad : public framework::OperatorWithKernel {
auto
table_dims
=
ctx
->
GetInputDim
(
"W"
);
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"W"
),
table_dims
);
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
ToDataType
(
ctx
.
Input
<
Tensor
>
(
"W"
)
->
type
());
}
};
}
// namespace operators
...
...
paddle/operators/multiplex_op.cc
浏览文件 @
2c05465d
...
...
@@ -50,6 +50,11 @@ class MultiplexOp : public framework::OperatorWithKernel {
}
ctx
->
SetOutputDim
(
"Out"
,
in_dim
);
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
ToDataType
(
ctx
.
MultiInput
<
Tensor
>
(
"X"
)[
0
]
->
type
());
}
};
class
MultiplexOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
...
...
@@ -99,6 +104,11 @@ class MultiplexGradOp : public framework::OperatorWithKernel {
}
ctx
->
SetOutputsDim
(
framework
::
GradVarName
(
"X"
),
d_ins
);
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
ToDataType
(
ctx
.
MultiInput
<
Tensor
>
(
"X"
)[
0
]
->
type
());
}
};
}
// namespace operators
...
...
paddle/operators/scatter_op.cc
浏览文件 @
2c05465d
...
...
@@ -48,6 +48,11 @@ class ScatterOp : public framework::OperatorWithKernel {
}
ctx
->
SetOutputDim
(
"Out"
,
ref_dims
);
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
ToDataType
(
ctx
.
Input
<
Tensor
>
(
"X"
)
->
type
());
}
};
class
ScatterGradOp
:
public
framework
::
OperatorWithKernel
{
...
...
@@ -60,6 +65,11 @@ class ScatterGradOp : public framework::OperatorWithKernel {
ctx
->
GetInputDim
(
"Updates"
));
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"Ref"
),
ctx
->
GetInputDim
(
"Ref"
));
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
ToDataType
(
ctx
.
Input
<
Tensor
>
(
"X"
)
->
type
());
}
};
class
ScatterOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
...
...
paddle/operators/softmax_with_cross_entropy_op.cc
浏览文件 @
2c05465d
...
...
@@ -13,6 +13,7 @@
limitations under the License. */
#include "paddle/operators/softmax_with_cross_entropy_op.h"
#include <paddle/function/TensorType.h>
namespace
paddle
{
namespace
operators
{
...
...
@@ -115,6 +116,11 @@ class SoftmaxWithCrossEntropyOp : public framework::OperatorWithKernel {
ctx
->
ShareLoD
(
"Logits"
,
/*->*/
"Softmax"
);
ctx
->
ShareLoD
(
"Logits"
,
/*->*/
"Loss"
);
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
ToDataType
(
ctx
.
Input
<
Tensor
>
(
"Logits"
)
->
type
());
}
};
class
SoftmaxWithCrossEntropyOpGrad
:
public
framework
::
OperatorWithKernel
{
...
...
@@ -149,6 +155,11 @@ class SoftmaxWithCrossEntropyOpGrad : public framework::OperatorWithKernel {
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"Logits"
),
ctx
->
GetInputDim
(
"Softmax"
));
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
ToDataType
(
ctx
.
Input
<
Tensor
>
(
"Logits"
)
->
type
());
}
};
}
// namespace operators
...
...
paddle/operators/uniform_random_op.cc
浏览文件 @
2c05465d
...
...
@@ -62,6 +62,11 @@ class UniformRandomOp : public framework::OperatorWithKernel {
}
ctx
->
SetOutputDim
(
"Out"
,
framework
::
make_ddim
(
temp
));
}
framework
::
DataType
IndicateDataType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
static_cast
<
framework
::
DataType
>
(
Attr
<
int
>
(
"data_type"
));
}
};
class
UniformRandomOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
...
...
@@ -80,6 +85,8 @@ Used to initialize tensor with uniform random generator.
"Random seed of uniform random. "
"0 means generate a seed by system"
)
.
SetDefault
(
0
);
AddAttr
<
int
>
(
"data_type"
,
"output tensor data type"
)
.
SetDefault
(
framework
::
DataType
::
FP32
);
}
};
}
// namespace operators
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录