Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
97aa44e0
提交
97aa44e0
authored
9月 10, 2012
作者:
Matthew Rocklin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add draft of MPI ops
上级
5a214815
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
155 行增加
和
0 行删除
+155
-0
io.py
theano/tensor/io.py
+155
-0
没有找到文件。
theano/tensor/io.py
浏览文件 @
97aa44e0
...
@@ -77,3 +77,158 @@ def load(path, dtype, broadcastable, mmap_mode=None):
...
@@ -77,3 +77,158 @@ def load(path, dtype, broadcastable, mmap_mode=None):
"""
"""
return
LoadFromDisk
(
dtype
,
broadcastable
,
mmap_mode
)(
path
)
return
LoadFromDisk
(
dtype
,
broadcastable
,
mmap_mode
)(
path
)
##########################
# MPI
##########################
try
:
from
mpi4py
import
MPI
comm
=
MPI
.
COMM_WORLD
mpi_enabled
=
True
except
:
mpi_enabled
=
False
class
MPIRecv
(
Op
):
"""
An operation to asynchronously receive an array to a remote host using MPI
See Also
MPIRecv
MPIWait
@note: Non-differentiable.
"""
def
__init__
(
self
,
rank
,
tag
,
dtype
,
shape
):
self
.
rank
=
rank
self
.
tag
=
tag
self
.
shape
=
shape
self
.
dtype
=
numpy
.
dtype
(
dtype
)
# turn "float64" into numpy.float64
self
.
broadcastable
=
(
False
,)
*
len
(
shape
)
self
.
_info
=
(
rank
,
tag
,
dtype
,
shape
)
def
__eq__
(
self
,
other
):
return
(
type
(
self
)
==
type
(
other
)
and
self
.
_info
==
other
.
_info
)
def
__hash__
(
self
):
return
hash
(
self
.
_info
)
def
make_node
(
self
):
return
gof
.
Apply
(
self
,
[],
[
theano
.
Generic
(),
tensor
(
self
.
dtype
,
broadcastable
=
self
.
broadcastable
)])
def
perform
(
self
,
node
,
inp
,
out
):
data
=
numpy
.
empty
(
self
.
shape
,
dtype
=
self
.
dtype
)
request
=
comm
.
Irecv
(
data
,
self
.
rank
,
self
.
tag
)
out
[
0
][
0
]
=
request
out
[
0
][
1
]
=
data
def
__str__
(
self
):
return
"MPIRecv{source:
%
d, tag:
%
d, dtype:
%
s, shape:
%
s, :
%
s}"
%
self
.
_info
class
MPIRecvWait
(
Op
):
"""
An operation to wait on a previously received array using MPI
See Also
MPIRecv
@note: Non-differentiable.
"""
def
__init__
(
self
):
pass
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
def
__hash__
(
self
):
return
hash
(
self
.
type
)
def
make_node
(
self
):
return
gof
.
Apply
(
self
,
[
theano
.
Generic
(),
tensor
(
self
.
dtype
,
broadcastable
=
self
.
broadcastable
)],
[
tensor
(
self
.
dtype
,
broadcastable
=
self
.
broadcastable
)])
def
perform
(
self
,
node
,
inp
,
out
):
request
=
inp
[
0
][
0
]
data
=
inp
[
0
][
1
]
request
.
wait
()
out
[
0
][
0
]
=
data
def
__str__
(
self
):
return
"MPIRecvWait"
class
MPISend
(
Op
):
"""
An operation to asynchronously Send an array to a remote host using MPI
See Also
MPIRecv
MPISendWait
@note: Non-differentiable.
"""
def
__init__
(
self
,
rank
,
tag
):
self
.
rank
=
rank
self
.
tag
=
tag
self
.
_info
=
(
rank
,
tag
)
def
__eq__
(
self
,
other
):
return
(
type
(
self
)
==
type
(
other
)
and
self
.
_info
==
other
.
_info
)
def
__hash__
(
self
):
return
hash
(
self
.
_info
)
def
make_node
(
self
):
return
gof
.
Apply
(
self
,
[
tensor
(
self
.
dtype
,
broadcastable
=
self
.
broadcastable
)],
[
theano
.
Generic
()])
def
perform
(
self
,
node
,
inp
,
out
):
data
=
inp
[
0
][
0
]
request
=
comm
.
Isend
(
data
,
self
.
rank
,
self
.
tag
)
out
[
0
][
0
]
=
request
def
__str__
(
self
):
return
"MPISend{dest:
%
d, tag:
%
d}"
%
self
.
_info
class
MPISendWait
(
Op
):
"""
An operation to wait on a previously sent array using MPI
See Also:
MPISend
@note: Non-differentiable.
"""
def
__init__
(
self
):
pass
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
def
__hash__
(
self
):
return
hash
(
self
.
type
)
def
make_node
(
self
):
return
gof
.
Apply
(
self
,
[
theano
.
Generic
()],
[])
def
perform
(
self
,
node
,
inp
,
out
):
request
=
inp
[
0
][
0
]
request
.
wait
()
def
__str__
(
self
):
return
"MPISendWait"
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论