Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
0c05ea39
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看板
提交
0c05ea39
编写于
9月 18, 2017
作者:
W
wanghaoshuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pull latest pybind.cc to crop_op
上级
46888c32
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
32 addition
and
4 deletion
+32
-4
paddle/operators/crop_op.cc
paddle/operators/crop_op.cc
+7
-0
paddle/operators/crop_op.cu
paddle/operators/crop_op.cu
+1
-2
paddle/operators/crop_op.h
paddle/operators/crop_op.h
+1
-2
paddle/pybind/pybind.cc
paddle/pybind/pybind.cc
+23
-0
未找到文件。
paddle/operators/crop_op.cc
浏览文件 @
0c05ea39
...
@@ -29,6 +29,10 @@ class CropOp : public framework::OperatorWithKernel {
...
@@ -29,6 +29,10 @@ class CropOp : public framework::OperatorWithKernel {
void
InferShape
(
const
framework
::
InferShapeContext
&
ctx
)
const
override
{
void
InferShape
(
const
framework
::
InferShapeContext
&
ctx
)
const
override
{
auto
x_dim
=
ctx
.
Input
<
LoDTensor
>
(
"X"
)
->
dims
();
auto
x_dim
=
ctx
.
Input
<
LoDTensor
>
(
"X"
)
->
dims
();
auto
Y
=
ctx
.
Input
<
LoDTensor
>
(
"Y"
);
auto
Y
=
ctx
.
Input
<
LoDTensor
>
(
"Y"
);
PADDLE_ENFORCE_NOT_NULL
(
ctx
.
InputVar
(
"X"
),
"Input(X) of CropOp should not be null."
);
PADDLE_ENFORCE_NOT_NULL
(
ctx
.
OutputVar
(
"Out"
),
"Output(Out) of CropOp should not be null."
);
if
(
Y
==
nullptr
)
{
if
(
Y
==
nullptr
)
{
auto
shape
=
Attr
<
std
::
vector
<
int
>>
(
"shape"
);
auto
shape
=
Attr
<
std
::
vector
<
int
>>
(
"shape"
);
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
...
@@ -40,6 +44,9 @@ class CropOp : public framework::OperatorWithKernel {
...
@@ -40,6 +44,9 @@ class CropOp : public framework::OperatorWithKernel {
}
}
ctx
.
Output
<
LoDTensor
>
(
"Out"
)
->
Resize
(
framework
::
make_ddim
(
tensor_shape
));
ctx
.
Output
<
LoDTensor
>
(
"Out"
)
->
Resize
(
framework
::
make_ddim
(
tensor_shape
));
}
else
{
}
else
{
PADDLE_ENFORCE_EQ
(
framework
::
arity
(
x_dim
),
framework
::
arity
(
Y
->
dims
()),
"Tensor rank of both CropOp's "
"inputs must be same."
);
ctx
.
Output
<
LoDTensor
>
(
"Out"
)
->
Resize
(
Y
->
dims
());
ctx
.
Output
<
LoDTensor
>
(
"Out"
)
->
Resize
(
Y
->
dims
());
}
}
}
}
...
...
paddle/operators/crop_op.cu
浏览文件 @
0c05ea39
...
@@ -19,8 +19,7 @@
...
@@ -19,8 +19,7 @@
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
using
Tensor
=
framework
::
Tensor
;
using
framework
::
LoDTensor
;
using
LoDTensor
=
framework
::
LoDTensor
;
template
<
typename
T
,
int
D
>
template
<
typename
T
,
int
D
>
__global__
void
CropKernel
(
const
int
N
,
const
int64_t
*
out_shape
,
__global__
void
CropKernel
(
const
int
N
,
const
int64_t
*
out_shape
,
...
...
paddle/operators/crop_op.h
浏览文件 @
0c05ea39
...
@@ -24,8 +24,7 @@ template <typename T, size_t D, int MajorType = Eigen::RowMajor,
...
@@ -24,8 +24,7 @@ template <typename T, size_t D, int MajorType = Eigen::RowMajor,
typename
IndexType
=
Eigen
::
DenseIndex
>
typename
IndexType
=
Eigen
::
DenseIndex
>
using
EigenTensor
=
framework
::
EigenTensor
<
T
,
D
,
MajorType
,
IndexType
>
;
using
EigenTensor
=
framework
::
EigenTensor
<
T
,
D
,
MajorType
,
IndexType
>
;
using
Tensor
=
framework
::
Tensor
;
using
framework
::
LoDTensor
;
using
LoDTensor
=
framework
::
LoDTensor
;
template
<
typename
Place
,
typename
T
,
size_t
D
>
template
<
typename
Place
,
typename
T
,
size_t
D
>
void
CropGradFunction
(
const
framework
::
ExecutionContext
&
context
)
{
void
CropGradFunction
(
const
framework
::
ExecutionContext
&
context
)
{
...
...
paddle/pybind/pybind.cc
浏览文件 @
0c05ea39
...
@@ -19,6 +19,7 @@ limitations under the License. */
...
@@ -19,6 +19,7 @@ limitations under the License. */
#include "paddle/framework/backward.h"
#include "paddle/framework/backward.h"
#include "paddle/framework/lod_tensor.h"
#include "paddle/framework/lod_tensor.h"
#include "paddle/framework/op_registry.h"
#include "paddle/framework/op_registry.h"
#include "paddle/operators/cond_op.h"
#include "paddle/operators/net_op.h"
#include "paddle/operators/net_op.h"
#include "paddle/operators/recurrent_op.h"
#include "paddle/operators/recurrent_op.h"
#include "paddle/platform/enforce.h"
#include "paddle/platform/enforce.h"
...
@@ -288,6 +289,28 @@ All parameter, weight, gradient are variables in Paddle.
...
@@ -288,6 +289,28 @@ All parameter, weight, gradient are variables in Paddle.
[](
operators
::
RecurrentOp
&
self
,
const
operators
::
NetOp
&
net
)
[](
operators
::
RecurrentOp
&
self
,
const
operators
::
NetOp
&
net
)
->
void
{
self
.
set_stepnet
(
net
.
Clone
());
});
->
void
{
self
.
set_stepnet
(
net
.
Clone
());
});
// cond_op
py
::
class_
<
operators
::
CondOp
,
OperatorBase
>
(
m
,
"CondOp"
)
.
def_static
(
"create"
,
[](
py
::
bytes
protobin
)
->
operators
::
CondOp
*
{
OpDesc
desc
;
PADDLE_ENFORCE
(
desc
.
ParsePartialFromString
(
protobin
),
"Cannot parse user input to OpDesc"
);
PADDLE_ENFORCE
(
desc
.
IsInitialized
(),
"User OpDesc is not initialized, reason %s"
,
desc
.
InitializationErrorString
());
auto
cond_op
=
OpRegistry
::
CreateOp
(
desc
);
return
static_cast
<
operators
::
CondOp
*>
(
cond_op
.
release
());
})
.
def
(
"set_truenet"
,
[](
operators
::
CondOp
&
self
,
const
operators
::
NetOp
&
net
)
->
void
{
self
.
set_truenet
(
net
.
Clone
());
})
.
def
(
"set_falsenet"
,
[](
operators
::
CondOp
&
self
,
const
operators
::
NetOp
&
net
)
->
void
{
self
.
set_falsenet
(
net
.
Clone
());
});
m
.
def
(
"unique_integer"
,
UniqueIntegerGenerator
);
m
.
def
(
"unique_integer"
,
UniqueIntegerGenerator
);
m
.
def
(
"is_compile_gpu"
,
IsCompileGPU
);
m
.
def
(
"is_compile_gpu"
,
IsCompileGPU
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录