Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2bd44678
提交
2bd44678
authored
9月 30, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a contexts config variable to specify the context map.
上级
8c9b612b
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
46 行增加
和
5 行删除
+46
-5
__init__.py
theano/__init__.py
+2
-1
configdefaults.py
theano/configdefaults.py
+23
-0
__init__.py
theano/sandbox/gpuarray/__init__.py
+8
-1
opt.py
theano/sandbox/gpuarray/opt.py
+4
-3
type.py
theano/sandbox/gpuarray/type.py
+9
-0
没有找到文件。
theano/__init__.py
浏览文件 @
2bd44678
...
@@ -112,7 +112,8 @@ if config.device.startswith('gpu') or config.init_gpu_device.startswith('gpu'):
...
@@ -112,7 +112,8 @@ if config.device.startswith('gpu') or config.init_gpu_device.startswith('gpu'):
if
(
config
.
device
.
startswith
(
'cuda'
)
or
if
(
config
.
device
.
startswith
(
'cuda'
)
or
config
.
device
.
startswith
(
'opencl'
)
or
config
.
device
.
startswith
(
'opencl'
)
or
config
.
init_gpu_device
.
startswith
(
'cuda'
)
or
config
.
init_gpu_device
.
startswith
(
'cuda'
)
or
config
.
init_gpu_device
.
startswith
(
'opencl'
)):
config
.
init_gpu_device
.
startswith
(
'opencl'
)
or
config
.
contexts
!=
''
):
import
theano.sandbox.gpuarray
import
theano.sandbox.gpuarray
# Use config.numpy to call numpy.seterr
# Use config.numpy to call numpy.seterr
...
...
theano/configdefaults.py
浏览文件 @
2bd44678
...
@@ -111,6 +111,29 @@ AddConfigVar(
...
@@ -111,6 +111,29 @@ AddConfigVar(
BoolParam
(
False
,
allow_override
=
False
),
BoolParam
(
False
,
allow_override
=
False
),
in_c_key
=
False
)
in_c_key
=
False
)
class
ContextsParam
(
ConfigParam
):
def
__init__
(
self
):
def
filter
(
val
):
if
val
==
''
:
return
val
for
v
in
val
.
split
(
';'
):
s
=
v
.
split
(
'->'
)
if
len
(
s
)
!=
2
:
raise
ValueError
(
"Malformed context map:
%
s"
%
(
v
,))
return
val
ConfigParam
.
__init__
(
self
,
''
,
filter
,
False
)
AddConfigVar
(
'contexts'
,
"""
Context map for multi-gpu operation. Format is a
semicolon-separated list of names and device names in the
'name->dev_name' format. An example that would map name 'test' to
device 'cuda0' and name 'test2' to device 'opencl0:0' follows:
"test->cuda0;test2->opencl0:0".
"""
,
ContextsParam
(),
in_c_key
=
False
)
AddConfigVar
(
AddConfigVar
(
'print_active_device'
,
'print_active_device'
,
"Print active device at when the GPU device is initialized."
,
"Print active device at when the GPU device is initialized."
,
...
...
theano/sandbox/gpuarray/__init__.py
浏览文件 @
2bd44678
...
@@ -51,6 +51,12 @@ if pygpu:
...
@@ -51,6 +51,12 @@ if pygpu:
elif
(
config
.
init_gpu_device
.
startswith
(
'cuda'
)
or
elif
(
config
.
init_gpu_device
.
startswith
(
'cuda'
)
or
config
.
init_gpu_device
.
startswith
(
'opencl'
)):
config
.
init_gpu_device
.
startswith
(
'opencl'
)):
init_dev
(
config
.
init_gpu_device
)
init_dev
(
config
.
init_gpu_device
)
if
config
.
contexts
!=
''
:
for
n
,
d
in
(
c
.
split
(
'->'
)
for
c
in
config
.
contexts
.
split
(
';'
)):
init_dev
(
d
,
n
)
import
theano.compile
theano
.
compile
.
shared_constructor
(
gpuarray_shared_constructor
)
optdb
.
add_tags
(
'gpuarray_opt'
,
'fast_run'
,
'fast_compile'
)
from
.basic_ops
import
(
GpuAlloc
,
GpuContiguous
,
GpuEye
,
GpuFromHost
,
from
.basic_ops
import
(
GpuAlloc
,
GpuContiguous
,
GpuEye
,
GpuFromHost
,
GpuJoin
,
GpuReshape
,
GpuSplit
,
HostFromGpu
)
GpuJoin
,
GpuReshape
,
GpuSplit
,
HostFromGpu
)
...
@@ -65,5 +71,6 @@ else:
...
@@ -65,5 +71,6 @@ else:
if
(
config
.
init_gpu_device
.
startswith
(
'cuda'
)
or
if
(
config
.
init_gpu_device
.
startswith
(
'cuda'
)
or
config
.
init_gpu_device
.
startswith
(
'opencl'
)
or
config
.
init_gpu_device
.
startswith
(
'opencl'
)
or
config
.
device
.
startswith
(
'opencl'
)
or
config
.
device
.
startswith
(
'opencl'
)
or
config
.
device
.
startswith
(
'cuda'
)):
config
.
device
.
startswith
(
'cuda'
)
or
config
.
contexts
!=
''
):
error
(
"pygpu was configured but could not be imported"
,
exc_info
=
True
)
error
(
"pygpu was configured but could not be imported"
,
exc_info
=
True
)
theano/sandbox/gpuarray/opt.py
浏览文件 @
2bd44678
...
@@ -170,8 +170,8 @@ class InputToGpuOptimizer(Optimizer):
...
@@ -170,8 +170,8 @@ class InputToGpuOptimizer(Optimizer):
continue
continue
try
:
try
:
ctx
=
getattr
(
input
.
tag
,
'context_name'
,
None
)
ctx
_name
=
getattr
(
input
.
tag
,
'context_name'
,
None
)
new_input
=
host_from_gpu
(
GpuFromHost
(
ctx
)(
input
))
new_input
=
host_from_gpu
(
GpuFromHost
(
ctx
_name
)(
input
))
fgraph
.
replace_validate
(
input
,
new_input
,
fgraph
.
replace_validate
(
input
,
new_input
,
"InputToGpuOptimizer"
)
"InputToGpuOptimizer"
)
except
TypeError
:
except
TypeError
:
...
@@ -180,7 +180,8 @@ class InputToGpuOptimizer(Optimizer):
...
@@ -180,7 +180,8 @@ class InputToGpuOptimizer(Optimizer):
except
ValueError
:
except
ValueError
:
# If there is no context tag and no default context
# If there is no context tag and no default context
# then it stays on the CPU
# then it stays on the CPU
assert
ctx
is
None
if
ctx
is
not
None
:
raise
pass
pass
...
...
theano/sandbox/gpuarray/type.py
浏览文件 @
2bd44678
...
@@ -469,6 +469,15 @@ def gpuarray_shared_constructor(value, name=None, strict=False,
...
@@ -469,6 +469,15 @@ def gpuarray_shared_constructor(value, name=None, strict=False,
if
not
isinstance
(
value
,
(
numpy
.
ndarray
,
pygpu
.
gpuarray
.
GpuArray
)):
if
not
isinstance
(
value
,
(
numpy
.
ndarray
,
pygpu
.
gpuarray
.
GpuArray
)):
raise
TypeError
(
'ndarray or GpuArray required'
)
raise
TypeError
(
'ndarray or GpuArray required'
)
try
:
get_context
(
context_name
)
except
ValueError
:
# Don't make this a hard error if we attempt to make a shared
# variable while there is no default context.
if
context_name
is
None
:
raise
TypeError
(
'No default context and no context specified'
)
raise
if
broadcastable
is
None
:
if
broadcastable
is
None
:
broadcastable
=
(
False
,)
*
value
.
ndim
broadcastable
=
(
False
,)
*
value
.
ndim
type
=
GpuArrayType
(
value
.
dtype
,
broadcastable
)
type
=
GpuArrayType
(
value
.
dtype
,
broadcastable
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论