Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6c6b8c43
提交
6c6b8c43
authored
9月 14, 2017
作者:
Frédéric Bastien
提交者:
GitHub
9月 14, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6405 from yikangshen/test_MRG_random_stream_target
test MRG random stream with device=cuda and target=cpu
上级
f881f23c
4686f603
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
45 行增加
和
8 行删除
+45
-8
dnn.py
theano/gpuarray/dnn.py
+2
-1
rng_mrg.py
theano/gpuarray/rng_mrg.py
+5
-2
config.py
theano/gpuarray/tests/config.py
+8
-3
test_rng_mrg.py
theano/gpuarray/tests/test_rng_mrg.py
+28
-1
test_rng_mrg.py
theano/sandbox/tests/test_rng_mrg.py
+2
-1
没有找到文件。
theano/gpuarray/dnn.py
浏览文件 @
6c6b8c43
...
@@ -119,7 +119,8 @@ def _make_handle(ctx):
...
@@ -119,7 +119,8 @@ def _make_handle(ctx):
with
ctx
:
with
ctx
:
err
=
cudnn
.
cudnnCreate
(
ctypes
.
byref
(
handle
))
err
=
cudnn
.
cudnnCreate
(
ctypes
.
byref
(
handle
))
if
err
!=
0
:
if
err
!=
0
:
raise
RuntimeError
(
"error creating cudnn handle"
)
raise
RuntimeError
(
"Error creating cudnn handle. "
"This can be a sign of a too old driver."
,
err
)
return
handle
return
handle
...
...
theano/gpuarray/rng_mrg.py
浏览文件 @
6c6b8c43
...
@@ -14,7 +14,7 @@ from theano.tensor import as_tensor_variable, get_vector_length
...
@@ -14,7 +14,7 @@ from theano.tensor import as_tensor_variable, get_vector_length
from
theano.scalar
import
int32
as
int_t
from
theano.scalar
import
int32
as
int_t
from
.basic_ops
import
(
GpuKernelBase
,
Kernel
,
infer_context_name
,
from
.basic_ops
import
(
GpuKernelBase
,
Kernel
,
infer_context_name
,
host_from_gpu
,
as_gpuarray_variable
)
GpuFromHost
,
host_from_gpu
,
as_gpuarray_variable
)
from
.type
import
GpuArrayType
,
gpu_context_type
from
.type
import
GpuArrayType
,
gpu_context_type
from
.fp16_help
import
write_w
from
.fp16_help
import
write_w
from
.opt
import
register_opt
,
register_opt2
from
.opt
import
register_opt
,
register_opt2
...
@@ -309,7 +309,10 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
...
@@ -309,7 +309,10 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
@register_opt2
([
mrg_uniform
],
'fast_compile'
)
@register_opt2
([
mrg_uniform
],
'fast_compile'
)
def
local_gpua_mrg_graph
(
op
,
context_name
,
inputs
,
outputs
):
def
local_gpua_mrg_graph
(
op
,
context_name
,
inputs
,
outputs
):
if
(
type
(
op
)
==
mrg_uniform
and
if
(
type
(
op
)
==
mrg_uniform
and
isinstance
(
inputs
[
0
]
.
type
,
GpuArrayType
)):
isinstance
(
inputs
[
0
]
.
type
,
GpuArrayType
)
and
(
inputs
[
0
]
.
owner
is
None
or
not
isinstance
(
inputs
[
0
]
.
owner
.
op
,
GpuFromHost
))):
outs
=
GPUA_mrg_uniform
.
new
(
inputs
[
0
],
outs
=
GPUA_mrg_uniform
.
new
(
inputs
[
0
],
op
.
output_type
.
ndim
,
op
.
output_type
.
ndim
,
op
.
output_type
.
dtype
,
op
.
output_type
.
dtype
,
...
...
theano/gpuarray/tests/config.py
浏览文件 @
6c6b8c43
...
@@ -7,15 +7,20 @@ import theano.gpuarray
...
@@ -7,15 +7,20 @@ import theano.gpuarray
if
theano
.
gpuarray
.
pygpu
is
None
:
if
theano
.
gpuarray
.
pygpu
is
None
:
raise
SkipTest
(
"pygpu not installed"
)
raise
SkipTest
(
"pygpu not installed"
)
init_error
=
None
if
(
not
theano
.
gpuarray
.
pygpu_activated
and
if
(
not
theano
.
gpuarray
.
pygpu_activated
and
not
theano
.
config
.
force_device
):
not
theano
.
config
.
force_device
):
try
:
try
:
theano
.
gpuarray
.
init_dev
(
'cuda'
)
theano
.
gpuarray
.
init_dev
(
'cuda'
)
except
Exception
:
except
Exception
as
e
:
pass
init_error
=
e
if
not
theano
.
gpuarray
.
pygpu_activated
:
if
not
theano
.
gpuarray
.
pygpu_activated
:
raise
SkipTest
(
"pygpu disabled"
)
if
init_error
:
raise
SkipTest
(
init_error
)
else
:
raise
SkipTest
(
"pygpu disabled"
)
test_ctx_name
=
None
test_ctx_name
=
None
...
...
theano/gpuarray/tests/test_rng_mrg.py
浏览文件 @
6c6b8c43
...
@@ -165,4 +165,31 @@ def test_validate_input_types_gpuarray_backend():
...
@@ -165,4 +165,31 @@ def test_validate_input_types_gpuarray_backend():
def
test_f16_nonzero
():
def
test_f16_nonzero
():
cpu_f16_nonzero
(
mode
=
mode
,
op_to_check
=
GPUA_mrg_uniform
)
try
:
# To have theano.shared(x) try to move on the GPU
theano
.
compile
.
shared_constructor
(
gpuarray_shared_constructor
)
cpu_f16_nonzero
(
mode
=
mode
,
op_to_check
=
GPUA_mrg_uniform
)
finally
:
theano
.
compile
.
shared_constructor
(
gpuarray_shared_constructor
,
remove
=
True
)
def
test_cpu_target_with_shared_variable
():
srng
=
MRG_RandomStreams
()
s
=
np
.
random
.
rand
(
2
,
3
)
.
astype
(
'float32'
)
x
=
gpuarray_shared_constructor
(
s
,
name
=
'x'
)
try
:
# To have theano.shared(x) try to move on the GPU
theano
.
compile
.
shared_constructor
(
gpuarray_shared_constructor
)
y
=
srng
.
uniform
(
x
.
shape
,
target
=
'cpu'
)
y
.
name
=
'y'
z
=
(
x
*
y
)
.
sum
()
z
.
name
=
'z'
fz
=
theano
.
function
([],
z
,
mode
=
mode
)
nodes
=
fz
.
maker
.
fgraph
.
toposort
()
assert
not
any
([
isinstance
(
node
.
op
,
GPUA_mrg_uniform
)
for
node
in
nodes
])
finally
:
theano
.
compile
.
shared_constructor
(
gpuarray_shared_constructor
,
remove
=
True
)
theano/sandbox/tests/test_rng_mrg.py
浏览文件 @
6c6b8c43
...
@@ -740,7 +740,8 @@ def test_f16_nonzero(mode=None, op_to_check=rng_mrg.mrg_uniform):
...
@@ -740,7 +740,8 @@ def test_f16_nonzero(mode=None, op_to_check=rng_mrg.mrg_uniform):
m
=
srng
.
uniform
(
size
=
(
1000
,
1000
),
dtype
=
'float16'
)
m
=
srng
.
uniform
(
size
=
(
1000
,
1000
),
dtype
=
'float16'
)
assert
m
.
dtype
==
'float16'
,
m
.
type
assert
m
.
dtype
==
'float16'
,
m
.
type
f
=
theano
.
function
([],
m
,
mode
=
mode
)
f
=
theano
.
function
([],
m
,
mode
=
mode
)
assert
any
(
isinstance
(
n
.
op
,
op_to_check
)
for
n
in
f
.
maker
.
fgraph
.
apply_nodes
)
assert
any
(
isinstance
(
n
.
op
,
op_to_check
)
for
n
in
f
.
maker
.
fgraph
.
apply_nodes
)
m_val
=
f
()
m_val
=
f
()
assert
np
.
all
((
0
<
m_val
)
&
(
m_val
<
1
))
assert
np
.
all
((
0
<
m_val
)
&
(
m_val
<
1
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论