Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
urhero
Paddle
提交
bea82122
P
Paddle
项目概览
urhero
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bea82122
编写于
9月 07, 2017
作者:
D
dangqingqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Expose LoDTensor to pybind.
上级
b59f3018
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
26 addition
and
0 deletion
+26
-0
paddle/pybind/pybind.cc
paddle/pybind/pybind.cc
+26
-0
未找到文件。
paddle/pybind/pybind.cc
浏览文件 @
bea82122
...
@@ -17,6 +17,7 @@ limitations under the License. */
...
@@ -17,6 +17,7 @@ limitations under the License. */
#include <vector>
#include <vector>
#include "paddle/framework/backward.h"
#include "paddle/framework/backward.h"
#include "paddle/framework/lod_tensor.h"
#include "paddle/framework/op_registry.h"
#include "paddle/framework/op_registry.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"
...
@@ -54,6 +55,7 @@ namespace paddle {
...
@@ -54,6 +55,7 @@ namespace paddle {
namespace
framework
{
namespace
framework
{
using
Tensor
=
framework
::
Tensor
;
using
Tensor
=
framework
::
Tensor
;
using
LODTensor
=
framework
::
LODTensor
;
static
size_t
UniqueIntegerGenerator
()
{
static
size_t
UniqueIntegerGenerator
()
{
static
std
::
atomic
<
size_t
>
generator
;
static
std
::
atomic
<
size_t
>
generator
;
...
@@ -113,6 +115,25 @@ PYBIND11_PLUGIN(core) {
...
@@ -113,6 +115,25 @@ PYBIND11_PLUGIN(core) {
return
self
.
data
<
float
>
()[
offset
];
return
self
.
data
<
float
>
()[
offset
];
});
});
py
::
class_
<
LODTensor
>
(
m
,
"LODTensor"
,
R"DOC(LOD(Leval of Ddetails) Tensor.
The tensor and LOD info should be created before creating the LODTensor, then
call the set_tensor and set_lod functions to set them.
)DOC"
)
.
def
(
"set_tensor"
,
[](
LODTensor
&
self
,
Tensor
*
tensor
)
{
self
.
set_tensor
(
tensor
);
})
.
def
(
"set_lod"
,
[](
LODTensor
&
self
,
std
::
vector
<
std
::
vector
<
size_t
>>
&
lod
)
{
self
.
set_lod
(
lod
);
})
.
def
(
"get_tensor"
,
[](
LODTensor
&
self
)
->
Tensor
&
{
return
self
.
tensor
();
},
py
::
return_value_policy
::
reference
)
.
def
(
"get_lod"
,
[](
LODTensor
&
self
)
->
std
::
vector
<
std
::
vector
<
size_t
>>
{
return
self
.
lod
();
});
py
::
class_
<
Variable
>
(
m
,
"Variable"
,
R"DOC(Variable Class.
py
::
class_
<
Variable
>
(
m
,
"Variable"
,
R"DOC(Variable Class.
All parameter, weight, gradient are variables in Paddle.
All parameter, weight, gradient are variables in Paddle.
...
@@ -124,6 +145,11 @@ All parameter, weight, gradient are variables in Paddle.
...
@@ -124,6 +145,11 @@ All parameter, weight, gradient are variables in Paddle.
.
def
(
"get_tensor"
,
.
def
(
"get_tensor"
,
[](
Variable
&
self
)
->
Tensor
*
{
return
self
.
GetMutable
<
Tensor
>
();
},
[](
Variable
&
self
)
->
Tensor
*
{
return
self
.
GetMutable
<
Tensor
>
();
},
py
::
return_value_policy
::
reference
)
py
::
return_value_policy
::
reference
)
.
def
(
"get_lod_tensor"
,
[](
Variable
&
self
)
->
LODTensor
*
{
return
self
.
GetMutable
<
LODTensor
>
();
},
py
::
return_value_policy
::
reference
)
.
def
(
"get_net"
,
.
def
(
"get_net"
,
[](
Variable
&
self
)
->
operators
::
NetOp
*
{
[](
Variable
&
self
)
->
operators
::
NetOp
*
{
return
self
.
GetMutable
<
operators
::
NetOp
>
();
return
self
.
GetMutable
<
operators
::
NetOp
>
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录