Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9cbd604e
提交
9cbd604e
authored
10月 13, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change the exception type when a context is not defined.
上级
d2de7531
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
6 行删除
+11
-6
opt.py
theano/sandbox/gpuarray/opt.py
+4
-3
type.py
theano/sandbox/gpuarray/type.py
+7
-3
没有找到文件。
theano/sandbox/gpuarray/opt.py
浏览文件 @
9cbd604e
...
...
@@ -17,7 +17,8 @@ from theano.scan_module import scan_utils, scan_op, scan_opt
from
theano.tensor.nnet.conv
import
ConvOp
from
theano.tests.breakpoint
import
PdbBreakpoint
from
.type
import
GpuArrayType
,
GpuArrayConstant
,
get_context
from
.type
import
(
GpuArrayType
,
GpuArrayConstant
,
get_context
,
ContextNotDefined
)
from
.basic_ops
import
(
as_gpuarray_variable
,
infer_context_name
,
host_from_gpu
,
GpuToGpu
,
HostFromGpu
,
GpuFromHost
,
...
...
@@ -177,7 +178,7 @@ class InputToGpuOptimizer(Optimizer):
except
TypeError
:
# This could fail if the inputs are not TensorTypes
pass
except
ValueError
:
except
ContextNotDefined
:
# If there is no context tag and no default context
# then it stays on the CPU
if
not
hasattr
(
input
.
tag
,
'context_name'
):
...
...
@@ -255,7 +256,7 @@ def local_gpuaalloc2(node):
"""
try
:
get_context
(
None
)
except
ValueError
:
except
ContextNotDefined
:
# If there is no default context then we do not perform the move here.
return
if
(
isinstance
(
node
.
op
,
tensor
.
Alloc
)
and
...
...
theano/sandbox/gpuarray/type.py
浏览文件 @
9cbd604e
...
...
@@ -17,6 +17,10 @@ except ImportError:
_context_reg
=
{}
class
ContextNotDefined
(
ValueError
):
pass
def
reg_context
(
name
,
ctx
):
"""
Register a context by mapping it to a name.
...
...
@@ -56,7 +60,7 @@ def get_context(name):
"""
if
name
not
in
_context_reg
:
raise
ValueError
(
"context name
%
s not defined"
%
(
name
,))
raise
ContextNotDefined
(
"context name
%
s not defined"
%
(
name
,))
return
_context_reg
[
name
]
...
...
@@ -72,7 +76,7 @@ def _name_for_ctx(ctx):
for
k
,
v
in
_context_reg
:
if
v
==
ctx
:
return
k
raise
ValueError
(
'context is not registered'
)
raise
ContextNotDefined
(
'context is not registered'
)
# This is a private method for use by the tests only
...
...
@@ -479,7 +483,7 @@ def gpuarray_shared_constructor(value, name=None, strict=False,
try
:
get_context
(
context_name
)
except
ValueError
:
except
ContextNotDefined
:
# 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
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论