Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PGL
提交
88b4ada0
P
PGL
项目概览
PaddlePaddle
/
PGL
通知
76
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
11
列表
看板
标记
里程碑
合并请求
1
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PGL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
11
Issue
11
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
88b4ada0
编写于
8月 06, 2020
作者:
Y
Yelrose
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add partial node feature
上级
361da2cc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
43 deletion
+18
-43
pgl/graph_wrapper.py
pgl/graph_wrapper.py
+18
-43
未找到文件。
pgl/graph_wrapper.py
浏览文件 @
88b4ada0
...
...
@@ -27,22 +27,24 @@ from pgl.utils.logger import log
__all__
=
[
"BaseGraphWrapper"
,
"GraphWrapper"
,
"StaticGraphWrapper"
]
def
send
(
src
,
dst
,
nfeat
,
efeat
,
message_func
,
nfeat_src
,
nfeat_dst
):
class
ReadRows
(
object
):
"""Memory Efficient ReadRows
"""
def
__init__
(
self
,
nfeat
,
index
):
self
.
nfeat
=
nfeat
self
.
loaded_nfeat
=
{}
self
.
index
=
index
def
__getitem__
(
self
,
key
):
if
key
not
in
self
.
loaded_nfeat
:
self
.
loaded_nfeat
[
key
]
=
op
.
read_rows
(
self
.
nfeat
[
key
],
self
.
index
)
return
self
.
loaded_nfeat
[
key
]
def
send
(
src
,
dst
,
nfeat
,
efeat
,
message_func
):
"""Send message from src to dst.
"""
for
key
in
nfeat_src
.
keys
():
if
key
in
nfeat
:
log
.
info
(
"Node-Feature %s both in nfeat_src_list and nfeat_list"
%
key
)
for
key
in
nfeat_dst
.
keys
():
if
key
in
nfeat
:
log
.
info
(
"Node-Feature %s both in nfeat_dst_list and nfeat_list"
%
key
)
nfeat_src
.
update
(
nfeat
)
nfeat_dst
.
update
(
nfeat
)
src_feat
=
op
.
read_rows
(
nfeat_src
,
src
)
dst_feat
=
op
.
read_rows
(
nfeat_dst
,
dst
)
src_feat
=
ReadRows
(
nfeat
,
src
)
dst_feat
=
ReadRows
(
nfeat
,
dst
)
msg
=
message_func
(
src_feat
,
dst_feat
,
efeat
)
return
msg
...
...
@@ -121,7 +123,7 @@ class BaseGraphWrapper(object):
def
__repr__
(
self
):
return
self
.
_data_name_prefix
def
send
(
self
,
message_func
,
nfeat_list
=
None
,
efeat_list
=
None
,
nfeat_list_src
=
None
,
nfeat_list_dst
=
None
):
def
send
(
self
,
message_func
,
nfeat_list
=
None
,
efeat_list
=
None
):
"""Send message from all src nodes to dst nodes.
The UDF message function should has the following format.
...
...
@@ -146,8 +148,6 @@ class BaseGraphWrapper(object):
message_func: UDF function.
nfeat_list: a list of names or tuple (name, tensor)
efeat_list: a list of names or tuple (name, tensor)
nfeat_list_src: a list of names or tuple (name, tensor). The node feature only for src
efeat_list_dst: a list of names or tuple (name, tensor). The node feature only for dst
Return:
A dictionary of tensor representing the message. Each of the values
...
...
@@ -160,12 +160,6 @@ class BaseGraphWrapper(object):
if
nfeat_list
is
None
:
nfeat_list
=
{}
if
nfeat_list_src
is
None
:
nfeat_list_src
=
{}
if
nfeat_list_dst
is
None
:
nfeat_list_dst
=
{}
src
,
dst
=
self
.
edges
nfeat
=
{}
...
...
@@ -176,24 +170,6 @@ class BaseGraphWrapper(object):
name
,
tensor
=
feat
nfeat
[
name
]
=
tensor
nfeat_src
=
{}
for
feat
in
nfeat_list_src
:
if
isinstance
(
feat
,
str
):
nfeat_src
[
feat
]
=
self
.
node_feat
[
feat
]
else
:
name
,
tensor
=
feat
nfeat_src
[
name
]
=
tensor
nfeat_dst
=
{}
for
feat
in
nfeat_list_dst
:
if
isinstance
(
feat
,
str
):
nfeat_dst
[
feat
]
=
self
.
node_feat
[
feat
]
else
:
name
,
tensor
=
feat
nfeat_dst
[
name
]
=
tensor
efeat
=
{}
for
feat
in
efeat_list
:
if
isinstance
(
feat
,
str
):
...
...
@@ -202,8 +178,7 @@ class BaseGraphWrapper(object):
name
,
tensor
=
feat
efeat
[
name
]
=
tensor
msg
=
send
(
src
,
dst
,
nfeat
,
efeat
,
message_func
,
nfeat_src
,
nfeat_dst
)
msg
=
send
(
src
,
dst
,
nfeat
,
efeat
,
message_func
)
return
msg
def
recv
(
self
,
msg
,
reduce_function
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录